1.0.6 • Published 23 days ago

react-native-bridtv-sdk-module v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
23 days ago

react-native-bridtv-sdk-module

BridTV SDK player for react native

Installation

npm install react-native-bridtv-sdk-module
or 
yarn add react-native-bridtv-sdk-module


IOS 

After NPM, cd to IOS and run  pod install

Android 

To update dependencies and fetch the latest packages open Android Studio and run Gradle Sync. By performing the Gradle sync, you ensure that your Android project is up to date with the latest packages and dependencies, which can help resolve compatibility issues and provide access to new features and bug fixes.

Usage

import { BridPlayer } from "react-native-bridtv-sdk-module";

// ...
const App = () => {
  const bridPlayerRef = React.useRef<BridPlayer>(null);

  const handleAllPlayerEvents = (eventData) => {
     console.log(eventData);
  };

  const handleVideoLoad = (eventData) => {cd
    console.log('VIDEO LOADED' + '-' + eventData.playerReference);
  };

          <BridPlayer
            ref={bridPlayerRef3}
            style={styles.square}
            bridPlayerConfig={{
              playerReference: 'player_3', // Player reference important for Events
              playerID: xxxx, // PlayerID from BridTV cms
              mediaID: xxxxxxxx, //VideoID or PlaylistID from BridTv cms
              typeOfPlayer: 'Single', // Single or Playlist
              controlAutoplay: false, //enables the client to take control over autoplay
              scrollOnAd: true, //This option enables scrolling during ad and is specific to the iOS platform. By default, Android has scrolling enabled during ads.
              creditsLabelColor: '614BC3', // To achieve color modification for credits label, it is necessary to provide a sequence of six hexadecimal characters, excluding the '#' symbol.
              setCornerRadius: 30, //This property enables setting the corner radius to the player itself. Its value is in pixels.
              localization: 'en', //This property allows selecting the language in which the player and IMA will operate.

            }}
            //Callback for Events from all players in one Activity {"message": "video/ad event", "playerReference": "reverence to player from props"}
            handleAllPlayerEvents={(eventData) =>handleAllPlayerEvents(eventData)}
            //Video
            handleVideoLoad={(eventData) => handleVideoLoad(eventData)}
            handleVideoStart={(eventData) => handleVideoStart(eventData)}
            //Error
            handleVideoError={(eventData) => handleVideoError(eventData)}
          />

Props

The BridPlayer component accepts the following props:

  • style (optional): Specifies the style for the player component.

  • bridPlayerConfig: An object that contains configuration options for the player. It includes properties playerID, mediaID, typeOfPlayer, useVPAIDSupport, playerReference, controlAutoplay, scrollOnAd, creditsLabelColor, setCornerRadius, localization. Explanations for each of the properties are given in the section above.

  • localization - Supported languages::

    • en (English) - default
    • es (Spanish)
    • de (German)
    • fr (French)
    • it (Italian)
    • ru (Russian)
    • pt (Portuguese)
    • sr (Serbian)
    • me (Montenegrin)
    • hr (Croatian)
    • bs (Bosnian)
    • sl (Slovenian)
  • handleAllPlayerEvents : Callback for Events from all players in one Activity {"name": "video/ad event", "playerReference": "reverence to player from props"}

  • Video event callbacks: These props allow you to specify callback functions for various video events like:

    • handleVideoLoad,
    • handleVideoStart,
    • handleVideoPlay,
    • handleVideoBuffering,
    • handleVideoProgress,
    • handleVideoPaused,
    • handleVideoEnd,
    • handleVideoSeek,
    • handleFullscreenOpen,
    • handleFullscreenClose,
    • handleVideoAutoplay
  • Ad event callbacks: These props allow you to specify callback functions for various ad events like:

    • handleVideoAdLoaded,
    • handleVideoAdCompleted,
    • handleVideoAdResumed,
    • handleVideoAdStart,
    • handleVideoAdPaused,
    • handleAdProgress,
    • handleVideoAdTapped,
    • handleVideoAdSkipped,
    • handleVideoAdEnd
  • handleVideoError: A callback function that handles video errors. It receives an errorEvent object. These are the error event types that can occur with the BridPlayer:

    • adError:

      • Name: adError
      • Message: Error occurred during ad playback.
      • Code: 300
    • videoBadUrl:

      • Name: playerVideoBadUrl
      • Message: Invalid video from BridTv CMS/Invalid video URL.
      • Code: 101
    • unsupportedFormat:

      • Name: playerUnsupportedFormat
      • Message: Video player error. Probably unsupported video format.
      • Code: 102
    • protectedContent:

      • Name: playerProtectedContent
      • Message: Cannot play protected content.
      • Code: 103
    • lostIntenetConnection:

      • Name: playerLostInternetConnection
      • Message: Lost internet connection.
      • Code: 100
    • liveStreamError:

      • Name: playerLivestreamError
      • Message: An error occurred during live stream playback.
      • Code: 200

These error types represent various issues that can occur during the playback of videos or ads with the BridPlayer. By handling these error events appropriately, you can provide better error feedback and take necessary actions to address the specific error conditions encountered during playback.

Methods

  • play(): void: Plays the video.
  • pause(): void: Pauses the video.
  • previous(): void: Plays the previous video in the playlist.
  • next(): void: Plays the next video in the playlist.
  • mute(): void: Mutes the video.
  • unMute(): void: Unmutes the video.
  • loadVideo(playerID: number, mediaID: number): void: Loads a video with the specified playerID and mediaID from BridTv CMS.
  • loadPlaylist(playerID: number, mediaID: number): void: Loads a playlist with the specified playerID and mediaID from BridTv CMS.
  • setFullscreen(fullscreen: boolean): void: Sets the fullscreen mode of the player. Pass true to enter fullscreen mode or false to exit fullscreen mode.
  • showControls(): void: Enable the video controls.
  • hideControls(): void: Disable the video controls.
  • showPoster(): void: Show video thumbnail.
  • hidePoster(): void: Hide video thumbnail.
  • isPlayingAd(): PromiseChecks if an ad is currently playing.
  • getPlayerCurrentTime(): Promise<number | null>: Retrieves the current playback time of the player in milliseconds. Returns a promise that resolves with the current time or null if the player is not loaded.
  • getAdDuration(): Promise<number | null>: Retrieves the duration of the currently playing ad in milliseconds. Returns a promise that resolves with the ad duration or null if no ad is playing.
  • getVideoDuration(): Promise<number | null>: Retrieves the duration of the currently loaded video in milliseconds. Returns a promise that resolves with the video duration or null if no video is loaded.
  • isPaused(): Promise: Checks if the video is currently paused.
  • isRepeated(): Promise: Checks if the video is already repeated.
  • destroyPlayer(): void: Destroys the native player instance and cleans up any resources associated with it.
  • isAutoplay(): Promise: Method is used to check if the current video is set to autoplay..

Please note that these methods should be called on an instance of the BridPlayer class.

Take a look at our Example App for best practices while implementing BridPlayer RN module.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made by Brid.tv

1.0.6

23 days ago

1.1.0

3 months ago

1.0.5

1 month ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

6 months ago

1.0.0

6 months ago

0.4.5

7 months ago

0.4.4

7 months ago

0.4.1

7 months ago

0.4.0

7 months ago

0.4.3

7 months ago

0.4.2

7 months ago

0.3.9

7 months ago

0.3.6

8 months ago

0.3.5

8 months ago

0.3.8

8 months ago

0.3.7

8 months ago

0.3.4

8 months ago

0.3.3

8 months ago

0.2.5-npo

9 months ago

0.3.0

9 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.2.7

9 months ago

0.1.8

10 months ago

0.2.6

9 months ago

0.1.7

10 months ago

0.2.9

9 months ago

0.2.8

9 months ago

0.1.9

10 months ago

0.3.2

8 months ago

0.2.3

9 months ago

0.1.4

12 months ago

0.3.1

8 months ago

0.2.2

9 months ago

0.1.6

11 months ago

0.2.4

9 months ago

0.1.5

11 months ago

0.1.3

12 months ago

0.1.2

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago