Reply
Visitor
joseph_shields
Posts: 9
Registered: ‎04-10-2012
0 Kudos

A few questions about Smart player API & modules

Hi there,

 

I have been setting up a simple video example the last few days and things were working fine, now moving into the smart API, I have been running up against some issues. Looking over forum and websites there seems to be a variety of methods for embedding. heres what Im doing.

 

<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/BrightcoveExperiences.js"></script>
<script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/APIModules.js"></script>

 

<script type="text/javascript">
var player;
var modExp;
var modVid;
var modCue;
var modCon;

 

function myTemplateLoaded(experienceID) {

console.log("1");

// get main BC experience
player = brightcove.getExperience(experienceID);

// get BC modules
modExp = player.getModule(APIModules.EXPERIENCE);
modVid = player.getModule(APIModules.VIDEO_PLAYER);
modCue = player.getModule(APIModules.CUE_POINTS);
modCon = player.getModule(APIModules.CONTENT);

modExp.addEventListener(BCExperienceEvent.TEMPLATE_READY, onTemplateReady);
modExp.addEventListener(BCExperienceEvent.CONTENT_LOAD, onContentLoad);

console.log("2");

function onTemplateReady(event) {
console.log("onTemplateReady");
}

function onContentLoad(event) {
console.log("onContentLoad");
}
}

</script>

 

Then I have the usual embed code as follows..

 

<object id="myExperience1543793011001" class="BrightcoveExperience">
<param name="bgcolor" value="#FFFFFF" />
<param name="width" value="480" />
<param name="height" value="270" />
<param name="playerID" value="1543801259001" />
<param name="playerKey" value="AQ~~,AAABZ2UOerk~,JiwdNLbJuAK8fyuDHPfmW_w9G7Ul-53x" />
<param name="isVid" value="true" />
<param name="isUI" value="true" />
<param name="dynamicStreaming" value="true" />
<param name="includeAPI" value="true" />
<param name="templateLoadHandler" value="myTemplateLoaded" />
<!-- <param name="@videoPlayer" value="1543793011001" /> -->
</object>

<script type="text/javascript">brightcove.createExperiences();</script>

 

So I get the "1" in the console but the "2" will not write out. If i remove the two event listeners the "2" will write to the log.

 

So my questions are:

 

1) Is my syntax corect for the event listeners? If yes, then is there any indication as to why they are not working ?

 

2) What is the significance of the number in "<object id="myExperience1543793011001". I see examples on the BC site that do not use the number and some that do. When gettignt he quick publish code the number is included. I assume is a video id. If I remove the number i get the experince not found error in the console. Is this number required ? 

 

3) If this is required and must be related to the video ID a specfiic video in my BC account, I repsume I can load additional videos into this experience wheile the user is on the page ? (eg from custom playlist)

 

4) Canyou clairfy which is the prefereed method for accessing Objects, should I be referencing modules directly or through their package path? eg modExp = player.getModule(APIModules.EXPERIENCE); vs modExp = player.getModule(brightcove.api.modules.APIModules.EXPERIENCE); 

 

Thanks in advance for any assistance.

 

J

 

 

Brightcove Team
BC-Oscar
Posts: 503
Registered: ‎12-11-2008
0 Kudos

Re: A few questions about Smart player API & modules

 

 Here are some answers:

 

 1. Try removing this line: <script language="JavaScript" type="text/javascript" src="http://admin.brightcove.com/js/APIModules.js"></script>. 

 

      It might be conflicting with the smartplayer api js file that gets loaded on runtime.

 

2.  You just any string there so there is an id for the object tag. The API uses this id to create a namespace for this id. It is useful for cases where you have multiple players in a page and want to get a reference to a specific one by id. It is not linked to any id in the Brightcove system

 

3.  @videoPlayer is really the video id parameter. This should be a video id in your account.  You can load new videos by callign the loadVideo or cueVideo APIs.

 

4. This is a good article with code samples on how to use the smart player api, including best practices. http://support.brightcove.com/en/docs/preparing-player-smart-player-api

Visitor
joseph_shields
Posts: 9
Registered: ‎04-10-2012
0 Kudos

Re: A few questions about Smart player API & modules

Thanks for your answers.

 

I removed the APIModules.js include, bbut got erros. So I added the complete package path to the getModule calls eg: 

 

modVid = bcExp.getModule(brightcove.api.modules.APIModules.VIDEO_PLAYER);

 

as opposed to 

 

modVid = bcExp.getModule(APIModules.VIDEO_PLAYER);

 

And I also noticed I was trying to use an event (brightcove.api.events.BCExperienceEvent.TEMPLATE_READY) which wasn't working so I renamed to (brightcove.api.events.ExperienceEvent.TEMPLATE_READY) and all is right n the world.

 

Thanks for your help again.

 

J