Skip to content

Instantly share code, notes, and snippets.

@gpittau
Last active December 20, 2015 11:09
Show Gist options
  • Save gpittau/6121575 to your computer and use it in GitHub Desktop.
Save gpittau/6121575 to your computer and use it in GitHub Desktop.
player_id='first-video-player';
function addCommand(id,command)
{
$('<button id="'+id+'">'+id+'</button></br>')
.click(command)
.appendTo('#qa-panel')
};
player=MP.players[player_id];
$('<div id="qa-panel">')
.css('position','fixed')
.css('top','20px')
.css('left','20px')
.css('height','200px')
.css('width','200px')
.css('background','green')
.appendTo(document.body)
addCommand('play',function(){MP.playMedia(player_id)})
addCommand('pause',function(){MP.pauseMedia(player_id)})
addCommand('stop',function(){MP.stopMedia(player_id)})
$('<textarea id="qa-log" rows=4>')
.appendTo('#qa-panel')
var l=$('#qa-log');
$.each(
[
'boltContentStarted',
'boltContentComplete',
'boltContentError',
'boltContentStateChanged',
'boltAdStarted',
'boltAdComplete',
'boltAdError',
//'boltAdRequestFailed',
'boltAdImpression',
//'boltAdClick',
'boltAdDurationChanged',
//'boltAdTimeChanged',
//'boltContentRequested',
//'boltRequestAdSpot',
//'boltLoaded',
//'boltToggleFullscreen',
//'boltAgeGate',
],function(n,event_name){
var qa_log=function(name){
return function(e,d){
l.text(l.text()+'\n'+(name+(d?': '+JSON.stringify(d):''))
)
}
}
MP.addEventListener(player_id,event_name,qa_log(event_name))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment