javascript - Add/remove class to video element -


i'm working on kiosk-style web page display menu of options. clicking on title opens fullscreen video closes menu when video ends.

to keep page clean, i'd hide video element until video called click. did css class. video opens fullscreen , when finished, closes , adds hide class again.

working script

$(document).ready(function() {   $('.cell').on('click', function() {     var element = this.getelementsbytagname('video');     var m = element[0].getattribute('id');      console.log(m);     var v = document.getelementbyid(m);     if (v.webkitrequestfullscreen) {       v.classname = "";       v.webkitrequestfullscreen();     }     v.play();      $("#" + m).on("ended", function() {       this.webkitexitfullscreen();       this.classname = "hide";     });   }) }) 

i'm running problem of video not hiding if user exits full screen video on own. tried using $("#" + m).on("ended" || "resize", function()... based on html5 video api, didn't work. i'd considered disabling clicks or overlaying full-screen div grab clicks , force video play way through, seems shady me. ideas on how approach this?

here's codepen demo of content , script

space separated list:

$("#" + m).on("ended resize" 

to make work might need trick: how detect div's dimension changed?

update: able catch fullscreen event:

$(document).on('webkitfullscreenchange mozfullscreenchange fullscreenchange', function(e){     console.log("fullscreen change"); }); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -