builtbywill / booklet

jQuery Plugin - display web content in a flipbook
http://builtbywill.com/booklet
Other
292 stars 109 forks source link

HTML5 Video won't autoplay inside a booklet #34

Closed SheikhYourass closed 10 years ago

SheikhYourass commented 10 years ago

Hey there!

I've added a video to my booklet and want it to start automatically. This works fine if I try the code outside the booklet. But when I add the same code inside the booklet the video can only be startet via the control bar.

Thanks in advance! =) Joe

builtbywill commented 10 years ago

You can target the video element(s) on the change event and fire the play() method. Additionally, you could pause them all as well when moving between pages.

$(".selector").booklet({
    start: function(event, data) {
        $('video').each(function(i){ 
            this.pause(); 
        });
    }, 
    change: function(event, data) {
        $.each(data.pages, function(index, value){
            $(this).find('video').each(function(i){
                this.play();
            });
         });
    }
});