Hey guys,
I building a flash plugin to track the plays on my sites, and I want to only send the request on the onStart event when the player plays Flash only event.
The request should only be sent once, so I couldn't use the onPlay event. And I couldn't use the playlist loaded event because the request was send when autostart was set to false.
If multiple items are in the playlist it should send the request on there onStart event. If the user finishes the video and plays it again from the begin the onStart event should fire again.
I think the js has an onStart event, but I am building a Flash plugin is there an equivalent?
Here's my test of an onstart event.
public function initPlugin(player:IPlayer, config:PluginConfig):void{
this.player = player;
this.config = config;
player.addEventListener(PlaylistEvent.JWPLAYER_PLAYLIST_LOADED, playlistHandler);
player.addEventListener(ViewEvent.JWPLAYER_VIEW_PLAY, onViewPlay);
player.addEventListener(MediaEvent.JWPLAYER_MEDIA_COMPLETE, onPlayerCompletion);
}
private function playlistHandler(event:PlaylistEvent):void
{
if(player.config.autostart == true) {
var publishedid:String = player.playlist.currentItem.mediaid;
var customerid:String = player.config['customerid'];
if(!requestSent) {
createRequest(publishedid, customerid);
}
}
}
private function onViewPlay(event:ViewEvent):void
{
if(player.config.duration < 1 && !requestSent) {
var publishedid:String = player.playlist.currentItem.mediaid;
var customerid:String = player.config['customerid'];
createRequest(publishedid, customerid);
}
}
private function onPlayerCompletion(event:MediaEvent):void
{
requestSent = false;
}