Question

I am adding new features, new skins... but I didn't wrote the first code. My boss told me that it's time to upgrade it. So, I downloaded the last version (4.3.0). The two versions are so different that I don't understand how to integrate the old code into the new version.

My first problem is that I don't know how to recuperate the value of the attribute which are on the video tag. I tried to compare with the existing code, but I am not really comfortable with Javascript that's why I'm trying to improve myself.

<video id="example_video_1" class="video-js" controls preload="auto" width="640" height="482" poster="" template="2" data-setup="{}" { "autoplay": false }>
 <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
 <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' />
 <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' />
</video>

My second problem is about the parameters passed to the video tag (like "template" above). I've got two functions :

  • Options : which is composed by the parameters that will be passed to the video tag (example : 'template', like above).
  • Config : which contains the variables that a video player needs (examples : 'preroll', and all the canvas stuff - that I don't know how to display by the way...).

I'm asking you if I'm doing the right thing. Do I need two functions in this version? Is there a simple way to pass to the old version to the new one?

Thank you, Léa.

Was it helpful?

Solution

So, I've found something to recuperate the different parameters which are in the video tag. My problem wasn't my function but the position of the script in the html.

Here is an example of my code :

vjs.getAvatarAttribute = function(){
    var videoTag = document.getElementsByTagName('video');
    var avatar = videoTag[0].getAttribute("avatar");
    if(avatar !== undefined){
        return avatar;
    }
}
if (vjs.getAvatarAttribute() !== undefined) { vjs.options.avatar = vjs.getAvatarAttribute(); }

So, this <script src="js/video.dev.js"></script> must be AFTER the video tag.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top