Smart Player to Brightcove Player API Comparison

Product(s)
Brightcove Player
Video Cloud
Role(s)
Player Developer
Topic(s)
Legacy Migration

In this topic you will learn about API differences when transitioning from Brightcove Smart Player to the Brightcove Player. You can learn more about Brightcove Player in the Overview: Brightcove Player document.

Plugins

You can create custom plugin code for both the Smart Player and the Brightcove Player, but you will see below that the process has been simplified for the Brightcove Player.

Smart Player

When creating plugins for the Smart Player, you have to do both:

  • Write a JavaScript plugin for when the player is in HTML5 mode
  • Write an equivalent SWF version of the plugin for when the player is in Flash mode

Here is an example code template for a Smart Player JavaScript plugin:

(function() {
    function onPlayerReady() {
        //Add functional JavaScript for your plugin here
    }

    var _player = brightcove.api.getExperience();
    var videoPlayer = _player.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);
    var experience = _player.getModule(brightcove.api.modules.APIModules.EXPERIENCE);

    if (experience.getReady()) {
        onPlayerReady();
    } else {
        experience.addEventListener(brightcove.player.events.ExperienceEvent.TEMPLATE_READY, onPlayerReady);
    }
}());

Brightcove Player

When creating plugins for the Brightcove Player, you only have to:

  • Write a JavaScript version of the plugin

Here is an example code template for a Brightcove Player plugin:

videojs.registerPlugin('pluginName', function() {
    var myPlayer = this;
    //Add functional JavaScript for your plugin here

});

Methods

The Brightcove Player uses HTML5 video methods whenever possible.

This table shows key methods used in the Smart Player and their equivalent counterparts in the Brightcove Player:

Smart Player Description Brightcove Player
templateLoadHandler() Loads the data for the player and the API This state does not exist in Brightcove Player
templateReadyHandler() Returns when the player is loaded and ready ready()
getExperience(id) Get a reference to the player videojs(id)
getModule(APIModules. VIDEO_PLAYER) Get a reference to the player's API modules This is not necessary in Brightcove Player
play() Start media playback play()
pause() Pause video playback pause()
addEventListener( event, handler, priority) Add an event handler for the specified event on( event, handler )
  Add an event handler to be triggered only once, and then removed one( event, handler )
removeEventListener( event, handler) Remove the event handler for an event off( event, handler )
getVideoDuration() Get the video length in seconds duration()
getCurrentVideo( callback with video DTO) Get video object for the currently playing video See mediainfo in Properties section below
getMediaByID(id, callback) Get video object by Id catalog.getVideo(videoId, callback)
loadVideoByID(id) BC Player: Load a video object into the player. The video object is returned from the catalog.getVideo() method.

Smart Player: Load a video for a given Id
catalog.load(video)
getPlaylistByID(id, callback) Get the playlist object for the specified Id catalog.getPlaylist(id, callback)
  BC Player: Load a playlist object into the player. The playlist object is returned from the catalog.getPlaylistByID() method.

Notice that the Brightcove Player breaks the getPlaylist()/load(playlist) into two parts for more flexibility.
catalog.load(playlist)
seek(seconds) Seek to a specified time position in the video currentTime(seconds)
getVideoPosition(format, callback) Get the current time in seconds currentTime()

Properties

This table shows key properties used in the Smart Player and their equivalent counterparts in the Brightcove Player:

Smart Player Description Brightcove Player
An object of type data.Media() An object that contains metadata for the current video in the player.

BC Player: This property is created and populated by the catalog.load() method.
mediainfo
Playlist object A data structure containing the properties for a playlist.

BC Player: This array of video objects is created and populated by the catalog.getPlaylist() method.

Smart Player: An object of type data.Playlist() created and populated by the getPlaylistByID() method.
Playlist object

Events

This table shows key events used in the Smart Player and their equivalent counterparts in the Brightcove Player:

Smart Player Dispatched when: Brightcove Player
templateLoad All data for the player and the API has been received by the browser This event has no equivalent in Brightcove Player
templateReady The player is instantiated and is ready to interact with the API ready
MediaEvent.CHANGE A new video is loaded into the player loadstart
  The player has initial media duration and dimension information loadedmetadata
  The first frame of the video has loaded loadeddata
MediaEvent.BEGIN The first time the media is played This event has no equivalent in Brightcove Player
MediaEvent.PLAY Media has begun or resumed playback play
MediaEvent.STOP Media has been paused or stopped pause
  A significant change in the amount of buffered video data occurs progress
MediaEvent.PROGRESS The current playback position has changed timeupdate
MediaEvent.COMPLETE The end of the media resource is reached ended
  The media is being seeked to a new position seeking
MediaEvent.SEEK_NOTIFY The media has been seeked to a new position seeked
MediaEvent.ERROR There was an error loading media error
  The duration of the media resource is first known or changed durationchange
  The player switches in or out of fullscreen mode fullscreenchange
  The width and/or height of the player changes resize
  The volume changes volumechange
  Playback stops because of a temporary lack of video data waiting