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