Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background video does not play on the first slide loaded #1314

Closed
denehyg opened this issue Jul 28, 2015 · 4 comments
Closed

Background video does not play on the first slide loaded #1314

denehyg opened this issue Jul 28, 2015 · 4 comments

Comments

@denehyg
Copy link
Contributor

denehyg commented Jul 28, 2015

When the first slide loaded contains a background video the video does not play, eg load or refresh http://lab.hakim.se/reveal-js/#/10/3

This has been seen on the following browsers:

  • Firefox on Mac OS X 10.10, Windows 7 and Linux
  • IE11 on Windows 7

The video plays as expected when loaded from Chrome on Mac OS X.

When trying to debug this using breakpoints in Firefox the video does play, so I would assume this is related to the async loading of the video.

@alexbatista
Copy link
Contributor

I had the the same problem, did you find any solutions for this?

@denehyg
Copy link
Contributor Author

denehyg commented Sep 28, 2015

No. The workaround for my use case is to manually advance the slide set and go back as this triggers the video playback. Works fine when I'm giving the presentation, but not so well if I'm directing others to a link.

@alexbatista
Copy link
Contributor

I think that i have a solution, is not good, but resolve the problem, if you can improve, please help me.

I did the following:

the error was in line 2616 i guess, where:
currentVideo.currentTime = 0;

probably the error occurs because the video was not loaded. Then, i change to this:

        var currentVideo = currentBackground.querySelector( 'video' );
        if( currentVideo ) {

            currentVideo.addEventListener("loadeddata", function() {
                currentVideo.currentTime = 0;
                currentVideo.play();
                loadeddata = true;
            });
            if(loadeddata === true){
                currentVideo.currentTime = 0;
                currentVideo.play();
            }
        }

I create a flag loadeddata for controller, i put on line 2548 above the declaration of the function updateBackground:
var loadeddata = false;
function updateBackground( includeAll ){
.....
}

In resume, i do this:

 var loadeddata = false; (line 2548)
function updateBackground( includeAll ){
    .....

     var currentVideo = currentBackground.querySelector( 'video' ); (line 2616)
        if( currentVideo ) {

            currentVideo.addEventListener("loadeddata", function() {
                currentVideo.currentTime = 0;
                currentVideo.play();
                loadeddata = true;
            });
            if(loadeddata === true){
                currentVideo.currentTime = 0;
                currentVideo.play();
            }
        }

   }

works fine on chrome and mozilla.

ps: sorry for my bad english, i am learning :)

about the event: https://developer.mozilla.org/en-US/docs/Web/Events/loadedmetadata

@hakimel
Copy link
Owner

hakimel commented Jan 8, 2016

Fixed by @alexbatista in #1376

@hakimel hakimel closed this as completed Jan 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants