2

I need to check if my jwplayer exist, For example, if i have two videos in page video1 and video2.

How do I check jwplayer("video1").exist() or jwplayer("video2").exist()

I want to remove the unique jwplayer player only if the unique jwplayer exist to avoid unnecessary error such as

uncaught typeerror undefined is not a function

I have tried onReady() but I think it is only executed once at intial state of player

onReady(callback) - Fired when the player has initialized in either Flash or HTML5 and is ready for playback. Has no attributes.

I have even tried this trick below but it did not work

 //checking if jwplayer media div exist
    var jw_mode = jwplayer('mediaId').getRenderingMode();
    if(jQuery('#'+mediaId).length){
       if( (jw_mode == 'html5') || (jw_mode == 'flash')) {
                alert("it works")
               //remove jwplayer from DOM
                 jwplayer(mediaId).remove();
       } 
    }

Above throws Error uncaught typeerror undefined is not a function if I use the wrong Id by mistake jwplayer("id")

so to avoid this problem I need to remove the player only if uniqueJwPlayer exist on close button instead of hiding it.

If (myUniqueJwPlayer.exist){
   jwplayer(myUniqueJwPlayer).remove()
}

How to do this in using Jwplayer

JSFIDDLE : http://jsfiddle.net/hiteshbhilai2010/nLr7k/25/

Hitesh
  • 4,098
  • 11
  • 44
  • 82
  • Do you have a link to where you are running this? – emaxsaun May 06 '14 at 15:04
  • @EthanJWPlayer - http://jsfiddle.net/hiteshbhilai2010/nLr7k/25/ Click on `show player` then quickly click on `remove player` when buffer is still loading. even player is removed you can hear the audio in background – Hitesh May 14 '14 at 14:16
  • It seems to remove fine for me and the audio goes away. What browser are you using? I was using FF 29. – emaxsaun May 14 '14 at 15:13
  • Hm, I checked Chrome on Win7, it seeks ok? – emaxsaun May 14 '14 at 17:10

0 Answers0