Ruby on Rails Wednesday, May 28, 2014

You've already done what you need to do -- you have a matching ID in the view and the JS ('example_video_1'). The only thing you need to ensure now is that you either have an unobtrusive listener function set to encapsulate the VideoJS script, or you load the VideoJS script after the video is on the page, so put that code at the bottom of the page.

An unobtrusive listener would look like this:

document.addEventListener('load', function(){
// your video_js code here
});

That would wait until the entire page had loaded, then fire the script to decorate the video with the alternate playback controls. It's often a better idea to just put the script at the bottom of the page, since that gets around any sort of issues with callbacks and observers not firing for any reason, or stalling the loading of CSS and leading to UX issues.

Walter

On May 28, 2014, at 4:01 PM, Pierre-Andre M. wrote:

> Understood...
>
> Here is some pure js that I substituted into the file as well and it
> does not render either.
>
>
>
> var endtime = 10505.89+10;
> myPlayer= document.getElementById('example_video_1');
> myPlayer.addEventListener('loadeddata', function(){
> example_video_1.currentTime = 10505.89;
> example_video_1.play();
> myPlayer.addEventListener('timeupdate', function(){
> if (example_video_1.currentTime >= endtime) {
> example_video_1.pause();
> }
>
> }, false);
>
> }, false);
>
>
> My question is, how do I get that elementID through my view back to
> this js file?
>
> The video ID is instantiated when I call the video tag in my view
>
> <video id="example_video_1" class="video-js vjs-default-skin" controls
> preload="auto" width="640" height="264"
> poster="http://video-js.zencoder.com/oceans-clip.png"
> data-setup="{}">
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2b4ac0090800a8b4a3dbf8b2182f3878%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2D3A5368-4EA8-4D79-BC2F-1CE2282F97BD%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment