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

external config file for a uniform player


Im trying to read if its possible to separate the playerInstance.setup() values.. to attain a uniform look of the player all over the site sirs?

Right now, I have this script embedded..

<script type="text/javascript" src="scripts/js/jwplayer/jwplayer.js"></script>
<script type="text/javascript" src="scripts/js/jwplayer.config.js"></script>

<script>
var playerInstance = jwplayer("MyVideo);
playerInstance.setup({
file: "tour-videos/movie-file.mp4",
image: "images/covers@320/movie-file.jpg",
width: "100%",
aspectratio: "16:9",
mediaid: '123456'
});
</script>

To explain further, I have exteranl jwplayer.config.js, which is at the moment.. only contains the jwplayer.key
But I would like to include there the other aspects of the player.. I mean the setup of the player.. instead of
writing a whole .setup.. which ofcourse will be repetitive all over the site.. that is what I want to eliminate..

So that in the end.. I will only have to write in the setup is the file directory.. and the image directory of the video..
is this possible..

To get a better understading sirs.. its kinda like this..


******************** this will be in the external file ******************************
config for all of the player in the site.. including skins.. etc etc..
for uniformity..

<script>
playerInstance.setup({
width: "100%",
aspectratio: "16:9",
mediaid: '123456'
});
</script>
******************** this will be in the external file ******************************



******************** this will be embedded on the page******************************
<script>
var playerInstance = jwplayer("MyVideo);
playerInstance.setup({
file: "tour-videos/movie-file.mp4",
image: "images/covers@320/movie-file.jpg",

});
</script>

******************** this will be embedded on the page******************************


I am leaning on this solution.. cause.. we have static pages that have unique videos.. diffrent
from one another.. so that it will easier to maintain..

5 Community Answers

Alex

JW Player Support Agent  
0 rated :

Hi, there.

My name is Alex and I am one of the Support Engineers at JW Player. I will be more than happy to assist you with your questions.

You should be able to by doing this:

this will be in the external file

var jwConfig = {
width: “100%”,
aspectratio: “16:9”
}

this will be embedded on the page

jwConfig.file = “tour-videos/movie-file.mp4”;
jwConfig.image = “images/covers@320/movie-file.jpg”;

var playerInstance = jwplayer(“myVideo”);
playerInstance.setup(jwConfig);

Please let me know if you need any more help or have any other questions.

Thank you!

Andrew

User  
0 rated :

Hi Alex,

Wow it worked great.. it needed some tweaks though.. but I finally made it to work..

How come I did not find that solution on the setup.. I think it will be better to include it on the
documentation...

Alex

JW Player Support Agent  
0 rated :

Hi, Andrew.

We try to keep our documentation as easy-to-follow as possible. We already have three different methods for embedding the player, so if you add this to the mix, it can confuse people even more. It’s an interesting idea though, and something we may want to include as a standalone article.

Thanks for the idea.

Andrew

User  
0 rated :

Hi alex,

Question, can jwconfig target a certain html page? So that i wont have to embed the js to every file??

I mean i will set a target page... And say that this movie file and poster is for this page.. And target it on a certain element??

Is that possible.. I have been reading all over the forum and could not find any docs about jwconfig.. Hoping to find answers ..

Also sir, i know jwplayer targets id to display the player.... But can it target classes too?

Alex

JW Player Support Agent  
0 rated :

Hi, Andrew.

I do not know of a way for a script to target a page without the script being embedded on the page. Also, the .setup() function needs to target the ID of a DIV, and it would actually overwrite any classes you put on the DIV.

Please let me know if you need any more help or have any other questions.

Thank you!

This question has received the maximum number of answers.