JWPlayer embed, FF but no Safari

ashleylovespizza / 2009-06-17 16:33:39   

Hey there,

I'm attempting to help with my friend's indexhibit site. We're using a pretty basic implementation of the jwplayer for his video section:

http://joshatlas.com/project/video/

Which works fine in Firefox but not in Safari. I have a feeling it's because we're using the old school object tag to embed it, instead of swfobject. This is because I can't figure out how to include swfobject as a js in every page.

Could you please take a look and tell me if you see why this would break in Safari? Or, how I can embed swfobject into the page's head tag?

thanks very much!
-ashley

Vaska A / 2009-06-17 16:45:25   

I usually put all my javascript into either the onlick or the href...but not both.

  1. <a href="JavaScript:player.sendEvent('LOAD', '/video_files/YouthWaste.flv')" onclick="$('#video_1').show();$('#video_2').hide();$('#video_3').hide();$('#video_4').hide();$('#video_5').hide();">Don't Let Our Youth Go to Waste</a>, 2007

Safari debugger says this when you click on things...

  1. TypeError: Result of expression 'player' [undefined] is not an object.

And, is there a script that holds the 'player.sendEvent' function? I don't see it...

Vaska A / 2009-06-17 16:48:02   

For hiding the vids...since you have the class there it might be easier to call it up...

  1. onclick="$('.video_caption').hide(); $('#video_1').show();">Don't Let Our Youth Go to Waste</a>

Etc...etc...could be streamlined much more easily now too...

ashleylovespizza / 2009-07-29 18:47:43   

Alright, got it figured out!

  1. Thanks Vaska for your help - pointing out that the player variable was undefined was the solution.  jwplayer's javascript embed default is this:
  2. var player = null;
  3. function playerReady(thePlayer) { player = window.document[thePlayer.id]; }
  4. jwplayer calls the playerReady function after the player has been fully loaded.  Safari I suppose has an issue with obtaining elements by id through a DOM array indice.  So I changed it to the below and all is well in all browsers now.
  5. var player = null;
  6. function playerReady(thePlayer) { player = window.document.getElementById(thePlayer.id); }

This thread has been closed, thank you.