Jwplayer - start detection

I am trying to detect the initial click in jwplayer. I embed it through swfobject, so the method is slightly different from the api example, http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/16024/listening-for-player-events

I tried

var flashvars = {
    'file':'xxx',
    'streamer':'xxxxxx',
'image':'xxxxx',
'plugins':'xxxxx',
'gapro.accountid':'xxxx',
'gapro.trackstarts':'xxxx',
'gapro.trackpercentage':'xxxx',
'gapro.tracktime':'xxxx',
'logo.file':'xxxxx',
'logo.link':'xxxx',
'logo.hide':'xxxx',
'logo.position':'xxxx'

};

jwplayer().onPlay(function() {alert('it has started'});

jwplayer () is not defined, how to define an object to detect a click?

+3
source share
1 answer

The player is probably undefined because it has not been created yet. You must wrap your command in a callback from a ready-made DOM listener. Since you are using jQuery, you can use your .ready () ( jQuery ) method :

$(document).ready(function(){
    jwplayer().onPlay(function() {alert('it has started'});
});

jwplayer onPlay(), , , , . , .

+7

All Articles