Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Is there a onStart Event Flash only?

3 replies [Last post]
Reply

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?

Reply

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;
}

Reply

@.11 -

This should more or less work. If the user interrupts playback (either by hitting a "stop" button or by navigating using the playlist) the complete event won't fire. Instead, I would additionally reset the requestSent variable to false in response to the PlaylistEvent.JWPLAYER_PLAYLIST_ITEM event.

Reply

Also, there is no "onStart" event in the HTML5 player either, so you'd have to do something similar.

Post new comment

  • Allowed HTML tags: <code> <blockquote> <em> <strong> <strike> <ul> <li> <ol>
  • You may post code using <code>...</code> .
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options