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

javascript event not working


The flash video works, but none of the event javascript methods execute.

I setup a demo here showing this issue, but do not want to publish it publicly, so if someone who works for longtailvideo.com can have me privately submit it, I'd appreciate. We just bought a full license for it too.

I'm doing the most basic alert on the event method onReady.
I thought maybe it was because I wasn't reference the jwplayer.js script correctly, but that isn't the issue. I tried hosting the jwplayer.js on my amazon S3 host, and my web server. Didn't make a difference. This demo has it hosted on the web server.

bc.. <div id="container">Loading the player ...</div>

<script type="text/javascript">
jwplayer("container").setup({
flashplayer: "url to swf file here",
file: "url to file here",
allowfullscreen: true,
wmode: "opaque",
height: 300,
width: 620,
allowscriptaccess: "always",
stretching: "exactfit",
events: {
onReady: function() {
alert('ready');
}
}
});

</script>

10 Community Answers

JW Player

User  
0 rated :

This is must be a BUG in the jwplayer-framework!

Take this little piece of code:
bc.. <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Test JW-Player</title>
<script type="text/javascript" src="jwplayer.js"></script>
</head>

<body>
<div id="outer_container" style="margin: 0 auto; text-align:center;">
<div id="inner_container">
<p>
To view our videos, please activate JavaScript and Flash.
</p>
</div>
</div>
<script type="text/javascript">
jwplayer("inner_container").setup({
flashplayer: "player.swf",
file: "video.mp4",
image: "preview.jpg",
width: 328,
height: 200,
events: {onReady: function () { alert("Ready"); }}
});
</script>
</body>
</html>



Test results on my system (win7 and jwplayer version 5.4.1492):

With Flash-Plugin uninstalled:
- Firefox 3.6.13: No onReady-event; just picture as download-link displayed --> correct! (Although disturbing since it overwrittes my nice littel advice abouve to activate flash and javascript. No everybody wants an uncommented download-link. Please provide an option to turn that off.)

- Opera 11 Build 1156: The same as Firefox --> correct!

- Safari 5.0.3. with Quicktime-Plugin and default Safari-user-agent: Player is loaded, jwplayer builts some controlls for the player, onReady-event is fired --> correct!

- Safari 5.0.3. with Quicktime-Plugin and iPhone-user-agent: Player is loaded, jwplayer uses completely quicktime, onReady-event fired --> correct!

- Internet Explorer 8.0.76 with Flash-ActiveX-Plugin: Player is loaded, NO onReady-event fired!! --> that seems to be WRONG!!!

With Flash-Plugin installed:
- In Firefox, Opera, Safari the available Flash plugin is now used. Player loads but no onReady-event is fired!! --> that seems to be WRONG!!!
- Internet Explorer: behaviour unchanged, uses ActiveX-Plugin, however no onReady-event fired!! --> that seems to be WRONG!!!

All in all: no onReady-event fired when Flash is used (an that's likely to be most of the cases). :-(((



JW Player

User  
0 rated :

http://developer.longtailvideo.com/player/trunk/fl5/js/test/examples/events.html is also working for me on Win7 and Firefox+Opera!

Strange.

I have just done this:
- Downloaded lastest version of jwplayer from longtailvideo's homepage.
- Extracted files to a folder on my desktop.
- Added the test.html file to the folder (see my first post; done according to "JW Player Embedding and JavaScript Guide.pdf")
- Installed latest flash-plugin.
- Ran the test.html file with Firefox.

Result: The video is played, however no event is fired (as described above).

Furthermore: Changing "file:video.mp4" to simply "http://content.bitsontherun.com/videos/gSzpo2wh-486405.mp4" in test.html doesn't work either. The "outside" video is not played.

Strange. I don't understand this... I wouldn't care about it, if it works on a real server environment and fails only the local system. Unfortunately I cannot test this at the moment since I don't have my own webspace yet.

JW Player

User  
0 rated :

events work for me (5.4.x), but i had to put the keys in quotes, e.g.:
bc.. ...
'events':
{
'onComplete': function(){ alert('done.') }
}
...



--u

JW Player

User  
0 rated :

Putting the keys in quotes doesn't make any difference: It's still not working on my local system.

JW Player

User  
0 rated :

I hope that this is only a strange behaviour on my local system and it will go away on real server environments. Unfortunately I don't have a webspace yet, so I cannot provide a link to a public page.

JW Player

User  
0 rated :

no, I tried this on server and events simply won't trigger, I tried it using different variations (quotes, chaining, external file...) but without any success.

JW Player

User  
0 rated :

I have now installed an Apache server on my system and tried to access the above test file (see my first post) via the server (http://localhost/jwplayer/test.html) and not just by directly loading it in the browser (file:///C:/Users/Oliver/Desktop/jwplayer/test.htmll)

Et voli: I got the ready-event!! Yippee!

So this seems to be definetely an issue of a missing server-environment (at least in my case).

Lessons learned: Do never ever develop a homepage without installing an Apache server on the system - even if Apache is used only locally - and test your stuff via the server. Otherwise, some events might not work (jwplayer), Ajax won't work either ...

JW Player

User  
0 rated :

hmm.. I just downloaded player from trunk, and hitting a problem that sounds similar.

In chrome on OS X my events fire fine.

In safari on OS X they fire fine

But in firefox 3.6.14 on OS X they dont.

on firefox 3.6.14 on ubuntu 10.04 they fire fine.

any thoughts?

JW Player

User  
0 rated :

Hi,

I'm having the same problem as Mark Lakewood.

It works on all browsers, except Firefox (Windows & OS X).
The player doesn't fire the onReady-event. Although, when I resize my browser, the event is fired.

Any suggestions?

JW Player

User  
0 rated :

OK, seems that Firefox stops all flashcontent when it is not visible.

I had an overlay that fades out when the player was ready. Removing it, solved the problem.

This question has received the maximum number of answers.