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

Dynamically Loading a Video Player


I am using premium version 6.12

Is there a sample anywhere about how to set up an embed code for a player that would be Dynamically Loaded on to a page? Like, what would the code below look like if it was Dynamically set for a player to work?

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

<script type="text/javascript">
jwplayer("container").setup({

file: “ http://www.youtube.com/v/JVnT6W8i_K8?” ,
sharing: {},
image: "http://www.mywebsite.com/images/prettyimage.jpg",
primary: "flash",
autostart: true,
skin: "five",
width: "100%",
aspectratio: "16:9"

});

</script>

6 Community Answers

George

JW Player Support Agent  
0 rated :

Hello Jose,

What exactly do you mean when you say dynamically, because you could do document.write and write the setup block but I wouldn’t say that works great. You could do document.write for an iframe. Seen it done, it’s ok.

Basically, tell me a little bit more about your use case and user flow, and we should be able to figure out something together.

jose

User  
0 rated :

Hi George,

We are trying to have a video on demand based on an user generated database. When attempting to load a player from a server database the player will not deploy for us.

The body script, when it is being resolved, the client side script is depending on the video information to already be there and it can’t be since the master script is created on the server and the files have to be changed after the fact when the user changes the video.

George

JW Player Support Agent  
0 rated :

Hello Jose,

Would it be possible to load the player with a generic video upon login of the user and then the user changes the video with the .load method?

jose

User  
0 rated :

Hi George,

Is there a way you can provide a sample embed code using the .load method?

George

JW Player Support Agent  
0 rated :

Hey Jose,

Not exactly the same scenario but the same method call. I’m loading a new playlist when the user clicks the button.
http://qa.jwplayer.com/~george/rss_playlist.html

wmeier

User  
0 rated :

@Jose

If you look on this page two entries below this one then you will see a code example of dynamically loading the JWPlayer.

You can use the following in several ways that will suit your needs

jwplayer('div1').load({image:'images/newyear2.jpg',sources:[{file:'blank.mp4'}]});

(a) replace image with your image
(b) replace sources -> file with your video

I hope that this answers your query.

Willie

This question has received the maximum number of answers.