Hey there, just a quick question from a newcomer.. I tried following the example at to extract information about the current video DTO in order to display it on my page. However, when accessing it via JS, the value of the video DTO always turns out to be undefined.
I've set up a custom template using videocloud with custom modules, and both the custom player and test video are playing correctly with the API enabled.
Below is the code snippet that I'm using to read the video DTO (specifically the 'BCSmain.displayVideoInfo' method):
/**** Brightcove Services Module ****/
var BCS = (function() {
// variables
var player,
APIModules,
videoPlayer,
adEvent,
captionsEvent,
contentEvent,
cuePointEvent,
mediaEvent;
// public functions and data
return {
/**** template loaded event handler ****/
onTemplateLoad: function(experienceID) {
// get references to the player, API Modules and Events
player = brightcove.api.getExperience(experienceID);
APIModules = brightcove.api.modules.APIModules;
adEvent = brightcove.api.events.AdEvent;
captionsEvent = brightcove.api.events.CaptionsEvent;
contentEvent = brightcove.api.events.ContentEvent;
cuePointEvent = brightcove.api.events.CuePointEvent;
mediaEvent = brightcove.api.events.MediaEvent;
BCSmain.bcslog("template loaded");
},
/**** template ready event handler ****/
onTemplateReady: function(evt) {
BCSmain.bcslog("template is ready");
// get references to modules
videoPlayer = player.getModule(APIModules.VIDEO_PLAYER);
// play current video
videoPlayer.play();
// display video information
videoPlayer.getCurrentVideo(BCSmain.displayVideoInfo);
}
};
}());
/**** Brightcove custom modules ****/
var BCSmain = (function() {
// variables
// public functions and data
return {
/**** display video information ****/
displayVideoInfo: function(videoDTO) {
console.log(videoDTO);
displayInfo.innerHTML += "<h3>About this video</h3>";
displayInfo.innerHTML += "<p>Title: " + videoDTO.displayName + "</p>";
displayInfo.innerHTML += "<p>Description: " + videoDTO.shortDescription +"</p>";
BCSmain.bcslog("video information has been updated");
},
/**** logging ****/
bcslog: function(message) {
if (window["console"] && console["log"]) {
var d = new Date();
console.log(d + ": " + message);
}
}
};
}());
Upon running the above script, the displayVideoInfo method is triggered.. but unfortunately, the videoDTO variable ends up being 'undefined', preventing the displayInfo from updating with the video information
Any idea what might be causing the 'undefined' value as the result for the videoPlayer.getCurrentVideo method? It's puzzling, considering I'm able to obtain correct values from videoPlayer.getCurrentRendition and all events are firing properly. Any assistance would be greatly appreciated, thank you!