javascript - Hide div when video starts -


i using youtube api put video on background of div, need detect when video ends loading, don't want show loading, before ends loading want show grey background, have gray background set, can't detect when starts instead of loading,

at moment have on javascript side:

    function onyoutubeiframeapiready() {         player = new yt.player('player', {             height: '360',             width: '640',             videoid: 'kn-1d5z3-cs',             autoplay: true,             startat: 10,             loop: 1,             playervars: { 'autoplay': 1, 'controls': 0, 'rel': 0, 'modestbranding': 1, 'showinfo': 0 },               events: {                 'onready': onplayerready,                 'onstatechange': onplayerstatechange             }         });     }      // 4. api call function when video player ready.     function onplayerready(event) {         player.mute();         event.target.playvideo();     }      // 5. api calls function when player's state changes.     //    function indicates when playing video (state=1),     //    player should play 6 seconds , stop.     var done = false;     function onplayerstatechange(e) {    if (event.data === 1) {      }     function stopvideo() {         player.stopvideo();     } </script> 

in html fine, need detect start of video , hide background div, how that?

i need detect start of video

there no start state youtube video player. can use event.data == 5 5 video cued state. that's because video cued state when video start. can take advantage of knowledge , hide div when it's on video cue.

from youtube events docs:

"when video cued , ready play, player broadcast video cued (5) event."


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -