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

load video from external js file not work


I'm trying to load file from external js file but it didn't work and also it didn't give me error
in my page I have this code:

<div class='content' id='mediaplayer'>Loading ...</div>
<script src='sidebar/radio/jwplayer/jwplayer.js'></script>
<script>
var player = jwplayer("mediaplayer");
player.setup({
skin: "sidebar/radio/jwplayer/skins/six.xml", width: "100%", height: 106, wmode: 'transparent',
file: doc.getElementById("playlist").value, autostart: true,
events: {
onError: function() {
player.remove();
doc.getElementById("mediaplayer").innerHTML = "<mark class='error'>There was error</mark>";
}
}
});
</script>

and in js file I have this function:

function load_media(rtmp) {
player.load([{ file: rtmp }]);
player.play();
}

it work if I use this function:

function load_media(rtmp) {
var player = jwplayer("mediaplayer");
player.setup({
skin: "sidebar/radio/jwplayer/skins/six.xml", width: "100%", height: 106, wmode: 'transparent',
file: doc.getElementById("playlist").value, autostart: true,
events: {
onError: function() {
player.remove();
doc.getElementById("mediaplayer").innerHTML = "<mark class='error'>There was error</mark>";
}
}
});
}

another question I load the url's using: file: doc.getElementById("playlist").value
but I found one of url's must loaded using: playlist: doc.getElementById("playlist").value
how can I switch between file: and playlist: in my function.

1 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi there,

Do you have your external JS file embedded at the end of the page before the closing </body> tag or in the <head> of your page? If it is embedded in the <head> of the document it will not work because that is running before your player is getting setup.

As for your second question – you should just be able to load a new playlist like this:

jwplayer().load([{
  "playlist": doc.getElementById("playlist").value
}]);

If that is not working, can you provide a URL to a reproduction page so I may see your page live?

Thank you.

This question has received the maximum number of answers.