Assigning Content to Players Programmatically

Product
Video Cloud
Applies to Roles
Publisher
Version
Brightcove 5
Edition
All

This document describes how to assign content to players programmatically in each of the Video Cloud publishing code types (JavaScript, ActionScript, HTML embed tag, and link URL).

Once you've uploaded your video content and created players, you need to tie them together so that the right player displays the right video content. Not all player templates permit you to assign playlists to them. If a player can't accept a playlist, it is labeled in the Media module "Publish videos to this player using Quick Publish or the Video Cloud APIs."

Required knowledge

Before starting, if you haven't already done so, upload some content to Video Cloud Studio by following the steps in Getting Started with the Media Module and Uploading Videos with the Media Module. In addition, if you haven't yet created a player, follow the steps in Studio Jumpstart: Making Your First Video Cloud Player to create a player.

To assign content to a player, you need to set parameters in the publishing code for the players, specifying the videos or playlists you want to play. You can use the ID or the reference ID to specify the videos or playlists, but you can't use both in the same publishing code. There are two ways to look up the video ID for a video:

  • In the Media module, locate the video in the Media Library and use the value in the ID column.
  • Look up the ID using the Video Cloud Media APIs. For example, you could use the find_videos_by_text method to return the video ID of a video with a given name.

Once you have located the IDs for the videos or playlists you want to play back in the player, there are a few ways to assign the content to your player. The method you choose depends on how you have published the player and how you need to control the content presented in the player. The syntax varies depending on the type of publishing code you have used.

There are also several other ways to assign content to players in the Media module. Read more about that in Assigning Content to Players using the Media Module and Quick Video Publishing. You can also use configuration parameters in the player publishing code to specify that the player should play a specific video from a playlist. Read more about this in Designating Featured Content in Players.

In this document, you will learn how to assign single videos or playlists to your players programmatically using each of the Video Cloud publishing code types:

JavaScript

JavaScript: Single video by video ID

To pass the video ID to a player that accepts a single video and is published using the JavaScript code, add the following parameter to your JavaScript publishing code:

<param name="@videoPlayer" value="12345" />

Where "12345" is the video ID for the video to playback in the player.

Example: JavaScript: Single video by video ID

The full HTML code used to publish the player and assign a video with ID "12345" to playback on load would be as follows:

<script  language="JavaScript" type="text/javascript" src="
http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
<object id="myPlayer"  class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="486" />
<param name="height" value="412" />
<param name="playerID" value="1234567890" />
<param name="playerKey" value="AQ~~,AAAAstMe5SE~,5vOZeV6rFDb4JUBomUtNzVLbOfHyhc1i" />
<param name="isVid" value="true" />
<param name="@videoPlayer"  value="12345" />
</object>

JavaScript: Single video by reference ID

To pass the reference ID to a player that accepts a single video and is published using the JavaScript code, add the following parameter to your JavaScript publishing code as follows:

<param name="@videoPlayer"  value="ref:myVid12345" />

where "myvid12345" is the reference ID for the video to playback in the player. Note how you need to prepend ref: to your reference ID.

Example: JavaScript: Single video by reference ID

The full HTML code used to publish the player and assign a video with ID "12345" to playback on load would be as follows:

<script  language="JavaScript" type="text/javascript" src="
http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
<object id="myPlayer"  class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="486" />
<param name="height" value="412" />
<param name="playerID" value="1234567890" />
<param name="playerKey" value="AQ~~,AAAAstMe5SE~,5vOZeV6rFDb4JUBomUtNzVLbOfHyhc1i" />
<param name="isVid" value="true" />
<param name="@videoPlayer"  value="ref:myVid12345" />
</object>

JavaScript: Playlist by playlist ID

To pass a playlist ID to a player that accepts multiple playlists and that is published using the JavaScript code, add the playlistTabs or playlistCombo parameter to your JavaScript publishing code as follows:

<param name="@playlistTabs"  value="6789"/>
<param name="@playlistCombo"  value="6789"/>

where "6789" is the playlist ID for the playlist to playback in the player. Use the playlistTabs config parameter for players with tabbed playlist selection and the playlistCombo config parameter for players with combo box (dropdown) playlist selection. To pass more than one playlist ID, include each of the playlist IDs, separated by commas:

<param name="@playlistTabs"  value="6789,9876,5432"/>

Players that get their content from a List or TabList component, such as the Widescreen with Horizontal List template, accept only a single playlist. To pass the playlist ID of a playlist to a player that accepts only a single playlist and that is published using the JavaScript code, add the videoList parameter to your JavaScript publishing code:

<param name="@videoList" value="6789"/>

Example: JavaScript: Playlist by playlist ID

The full HTML code used to publish the player and assign a playlist with ID 6789 to playback on load would be as follows:

<script  language="JavaScript" type="text/javascript"
src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
<object id="myPlayer"  class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="790" />
<param name="height" value="529" />
<param name="playerID" value="1234567890" />
<param name="playerKey" value="AQ~~,AAAAstMe5SE~,5vOZeV6rFDb4JUBomUtNzVLbOfHyhc1i" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="@playlistTabs"  value="6789" />
</object>

JavaScript: Playlist by reference ID

To pass the reference ID of a playlist to a player that accepts multiple playlists and that is published using the JavaScript code, add the playlistTabs or playlistCombo parameter to your JavaScript publishing code and prepend ref: to your reference ID in the parameter's value as follows:

<param name="@playlistTabs"  value="ref:myPlaylist6789"/>
<param name="@playlistCombo"  value="ref:myPlaylist6789"/>

Where "myplaylist6789" is the reference ID for the playlist to playback in the player. To pass more than one playlist by reference ID, prepend ref: to a comma-separated list of the reference IDs of each of the playlists. Make sure there is no white space between the comma-separated items.

<param name="@playlistTabs"  value="ref:myPlaylist6789,yourPlaylist9876,herPlaylist5432"/>

Players that get their content from a List or TabList component, such as the Widescreen with Horizontal List template, accept only a single playlist. To pass the reference ID of a playlist to a player that accepts only a single playlist and that is published using the JavaScript code, add the videoList parameter to your JavaScript publishing code and prepend ref: to your reference ID in the parameter's value:

<param name="@videoList"  value="ref:myPlaylist6789"/>

Example: JavaScript: Playlist by reference ID

The full HTML code used to publish the player and assign a playlist with reference ID myPlaylist6789 to playback on load would be as follows:

<script  language="JavaScript" type="text/javascript" 
src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
<object id="myPlayer"  class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="790" />
<param name="height" value="529" />
<param name="playerID" value="1234567890" />
<param name="playerKey" value="AQ~~,AAAAstMe5SE~,5vOZeV6rFDb4JUBomUtNzVLbOfHyhc1i" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="@playlistTabs"  value="ref:myPlaylist6789" />
</object>

ActionScript

ActionScript: Single video by video ID

To pass the video ID to the player that accepts a single video and is published with ActionScript, use the videoPlayer config parameter, as follows:

config["@videoPlayer"] = "12345";

Where "12345" is the video ID to playback in the player. Add this config parameter to the ActionScript publishing code for the player that you copied from the Publishing module.

ActionScript: Single video by reference ID

To pass the reference ID of a video to the player that accepts a single video and is published with ActionScript, use the videoPlayer config parameter and prepend ref: to your reference ID, as follows:

config["@videoPlayer"] = "ref:myVideo12345";

Where "myVideo12345" is the reference ID of the video to playback in the player. Add this config parameter to the ActionScript publishing code for the player that you copied from the Publishing module.

ActionScript: Playlist by playlist ID

To pass the playlist ID to a player that accepts multiple playlists and is published with ActionScript, use the playlistTabs or playlistCombo config parameter, as follows:

config["@playlistTabs"] = "6789";
config["@playlistCombo"] = "6789";

Where "6789" is the playlist ID to playback in the player. Use the playlistTabs config parameter for players with tabbed playlist selection and the playlistCombo config parameter for players with combo box (dropdown) playlist selection. Add the config parameter to the ActionScript publishing code for the player that you copied from the Publishing module. To pass more than one playlist ID, include each of the playlist IDs, separated by commas:

config["@playlistTabs"] = "6789,9876,5432";

Players that get their content from a List or TabList component, such as the Widescreen with Horizontal List template, accept only a single playlist. To pass the playlist ID of a playlist to a player that accepts only a single playlist and that is published using the ActionScript code, add the videoList parameter to your ActionScript publishing code as follows:

config["@videoList"] = "6789";

ActionScript: Playlist by reference ID

To pass the reference ID of a playlist to a player that accepts multiple playlists and is published with ActionScript, use the playlistTabs or playlistCombo config parameter and prepend ref: to your reference ID, as follows:

config["@playlistTabs"] = "ref:myPlaylist6789";
config["@playlistCombo"] = "ref:myPlaylist6789";

Where "myPlaylist6789" is the reference ID of the playlist to playback in the player. Add this config parameter to the ActionScript publishing code for the player that you copied from the Publishing module. To pass more than one reference ID, prepend ref: to a comma-separated list of the reference IDs. Make sure there is no white space between the comma-separated items.

config["@playlistTabs"] = "ref:myPlaylist6789,myPlaylist9876,myPlaylist5432";

Players that get their content from a List or TabList component, such as the Widescreen with Horizontal List template, accept only a single playlist. To pass the reference ID of a playlist to a player that accepts only a single playlist and that is published using the ActionScript code, add the videoList parameter to your ActionScript publishing code and prepend ref: to the reference ID of the playlist:

config["@videoList"] = "ref:myPlaylist6789";

HTML Embed

HTML Embed: Single video by video ID

To pass the video ID to the player that accepts a single video and is embedded using HTML, add &@videoPlayer=12345 after the playerID in the HTML embed code, where "12345" is the video ID you wish to play back This must be added after both occurrences of playerID in the embed code.

Example: HTML Embed: Single Video by video ID

Sample HTML code to embed to force playback of a video with ID = 12345:

<object id="flashObj" width="486" 
     height="412" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0"> 
   <param name="movie" value="http://c.brightcove.com/services/viewer/federated_f9/19174954001?isVid=1" /> 
   <param name="bgcolor" value="#FFFFFF" /> 
   <param name="flashVars" value="playerID=12345678900&@videoPlayer=12345&domain=embed&" />

   <param name="base" value="http://admin.brightcove.com" /> 
   <param name="seamlesstabbing" value="false" /> 
   <param name="allowFullScreen" value="true" /> 
   <param name="swLiveConnect" value="true" /> 
   <param name="allowScriptAccess" value="always" /> 
   
   <embed src="http://c.brightcove.com/services/viewer/federated_f9/19174954001?isVid=1" 
     bgcolor="#FFFFFF" flashVars="playerID=12345678900&@videoPlayer=12345&domain=embed&" 
     base="http://admin.brightcove.com" name="flashObj" width="486" 
     height="412" seamlesstabbing="false" type="application/x-shockwave-flash" 
     allowFullScreen="true" swLiveConnect="true" 
     allowScriptAccess="always" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> 
   </embed>

</object>

HTML Embed: Single video by reference ID

To pass the reference ID of a video to a player that accepts a single video and is embedded using HTML, add &@videoPlayer=ref:myVideo12345 after the playerID in the HTML embed code, where "myVideo12345" is the video ID you wish to play back. This must be added after both occurrences of playerID in the embed code.

HTML Embed: Playlist by playlist ID

To pass the playlist ID to a player that accepts multiple playlists and is embedded using HTML, add &@playlistTabs=6789 or &@playlistCombo=6789 after the playerID in the HTML embed code, where "6789" is the playlist ID you wish to playback. To pass more than one playlist ID, include each of the playlist IDs, separated by commas: &@playlistTabs=6789,9876,5432

If your player only accepts a single playlist, use the @videoList parameter instead: &@videoList=6789.

This must be added after both occurrences of playerID in the embed code.

Example: HTML Embed: Playlist by playlist ID

The following is sample HTML code to embed to force playback of a playlist with ID = 6789:

<object id="flashObj" width="486" height="412" 
        classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,47,0"> 
    <param name="movie" 
        value="http://c.brightcove.com/services/viewer/federated_f9/19174954001?isVid=1&isUI=1" /> 
    <param name="bgcolor" value="#FFFFFF" /> 
    <param name="flashVars" value="playerID=12345678900&@playlistTabs=6789&domain=embed&" />

    <param name="base" value="http://admin.brightcove.com" /> 
    <param name="seamlesstabbing" value="false" /> 
    <param name="allowFullScreen" value="true" />

    <param name="swLiveConnect" value="true" /> 
    <param name="allowScriptAccess" value="always" /> 
    
    <embed src="http://c.brightcove.com/services/viewer/federated_f9/19174954001?isVid=1&isUI=1" 
      bgcolor="#FFFFFF" flashVars="playerID=12345678900&@playlistTabs=6789&domain=embed&" 
      base="http://admin.brightcove.com" name="flashObj" 
      width="486" height="412" seamlesstabbing="false" 
      type="application/x-shockwave-flash" allowFullScreen="true" 
      swLiveConnect="true" allowScriptAccess="always" 
      pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> 
    </embed>

</object>

HTML Embed: Playlist by reference ID

To pass the reference ID of a playlist to a player that accepts multiple playlists and is embedded using HTML, add the following:

&@playlistTabs=ref:myPlaylist6789 or &@playlistCombo=ref:myPlaylist6789

Add this code after the playerID in the HTML embed code, where "myPlaylist6789" is the reference ID of the playlist you wish to play back. To pass more than one reference ID, prepend ref: to a comma-separated list of the reference IDs as follows:

&@playlistTabs=ref:myPlaylist6789,myPlaylist9876,myPlaylist5432

Make sure there is no white space between the comma-separated items.

If your player only accepts a single playlist, use the @videoList parameter instead, as follows: &@videoList=ref:myVideo6789.You must add this after both occurrences of playerID in the embed code.

Link URL

Modifying the Player URL: Single video by video ID

You can include the video ID in the URL to a Video Cloud-hosted player by appending ?bctid=12345 to the Player URL, where "12345" is the video ID you wish to playback. For example:

http://link.brightcove.com/services/player/bcpid0789?bctid=12345

If you are hosting the player using the JavaScript code on your own site, you can also modify the URL to force playback of a particular video. Append ?bctid=12345 to the URL where you are hosting the player, where "12345" is the video ID you wish to playback. For example:

http://www.myexamplesite.com/playerpage.html?bctid=12345

Modifying the Player URL: Single video by reference ID

You can use the reference ID of a video instead of its video ID in the player URL. Append ?bctid=ref:myvid123 to the player URL, where myvid123 is the reference ID of the video you want to play. For example:

http://link.brightcove.com/services/player/bcpid0789?bctid=ref:myvid123

If you are hosting the player using the JavaScript code on your own site, you can also modify the URL to force playback of a particular video. Append ?bctid=ref:myvid123 to the player URL, where myvid123 is the reference ID of the video you want to play. For example:

http://www.myexamplesite.com/playerpage.html?bctid=ref:myvid123

Modifying the Player URL: Playlist by playlist ID

You can include the playlist ID in the URL to the Brightcove-hosted player by appending ?bclid=6789 to the Player URL, where "6789" is the playlist ID you want to play. For example:

http://link.brightcove.com/services/player/bcpid0789?bclid=6789

Note that you cannot use this approach to include multiple playlists in a player.

If you are hosting a player using the JavaScript code on your own site, you can also modify the URL to force playback of a particular playlist. Append ?bclid=6789 to the URL where you are hosting the player, where "6789" is the playlist ID you want to play. For example:

http://www.myexamplesite.com/playerpage.html?bclid=6789

Modifying the Player URL: Playlist by reference ID

You can use the reference ID of a playlist instead of its playlist ID in the player URL. Append ?bclid=ref:mylist123 to the player URL, where mylist123 is the reference ID of the playlist you want to play. For example:

http://link.brightcove.com/services/player/bcpid0789?bclid=ref:mylist123

If you are hosting the player using the JavaScript code on your own site, you can also modify the URL to force playback of a particular playlist. Append ?bctid=ref:mylist123 to the player URL, where mylist123 is the reference ID of the playlist you want to play. For example:

http://www.myexamplesite.com/playerpage.html?bclid=ref:mylist123

Related resources

Read more about assigning content to players in the Programming Players section.

Tags
config params, publishing code