Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

OnPlay Event not firering


Hi,

I am new to jwplayer and I have a strange problem.

I have two pages playing different streams. In the fist page, this is the one that is displayed first, the onPlay event works fine. When I redirect to the second page, the jwplayer is reconfigured using another div as container butthe onPlay event is not anymore fired.

I am working on Single Page Application so when the second page is displayed, in fact, the first page is still in memory, addressed by another hash anchor.

Why is this happening. The second setup is correct, in fact I have a Singleton Javascript class the reconfigures the player in another container. It is playing the correct movie in both containers but the onPlay event does not fire anymore.

As I have an SPA maybe I should reset the player and setup it again. I presumed that setup would do this, but this is not happening. If this is the problem how can I completelly reset jwplayer before the new setup.

the code is right below:

bc.. function play(camera, divContent) {

var flash = {};
var http = {};

if (camera.cameraModes[0].modeType === 'flash') {
flash = camera.cameraModes[0];
http = camera.cameraModes[1];
}
else {
flash = camera.cameraModes[1];
http = camera.cameraModes[0];
}
var stretching = camera.stretching;
var autostart = camera.autoStart;
var bufferlength = camera.bufferLength;
var volume = camera.volume;
var aboutText = camera.aboutText;
var aboutLink = camera.aboutLink;
var marcaDagua = camera.imagem;

var flashModeConfig = {};
var html5ModeConfig = {};

flashModeConfig = { provider: flash.providerType, file: flash.file, streamer: flash.streamer }
html5ModeConfig = { provider: http.providerType, file: http.file };

var modes = [
{ type: 'flash', src: '../../App/util/swf/player.swf', config: flashModeConfig },
{ type: 'html5', config: html5ModeConfig }
];

streamPlayer.jwConfig = {
'id': divFlashContent,
'width': width,
'height': height,
'modes': modes,
'bufferlength': bufferlength,
'autostart': autostart,
'start': start,
'stretching': stretching,
'volume': volume,
'abouttext': aboutText,
'aboutlink': aboutLink,
'image': marcaDagua,
'width': '100%',
'height': '100%',
};

jwplayer(divContent).setup(streamPlayer.jwConfig);
jwplayer().onPlay(onPlay);
jwplayer().onPause(onPause);
}

function onPlay() {
startPlaying();
}


2 Community Answers

JW Player

User  
0 rated :

I have found the solution.

Instead of defining the events like this:

bc.. jwplayer().onPlay(onPlay);
jwplayer().onPause(onPause);



I have defined the events object and included in the setup like this:

bc.. var events = { 'onPlay': onPlay, 'onPause': onPause, 'onError': onError };


Ethan Feldman

JW Player Support Agent  
0 rated :

Glad you got it working.

This question has received the maximum number of answers.