javascript - iframe youtube video control -
hi,
i m new javascript , html5(just started 3 weeks ago) questions maybe bit stupid.
so know if s posible stop youtube video mouseleave.function...
i ve music wich play on website, when rollover youtube video music stop , did :
$(video).mouseenter(function(){ audioelement.pause(); }); than can play youtube video ...
when leave video player music goes on again , use :
$(video).mouseleave(function(){ audioelement.play(); }); but make youtube video stop @ same time because sound of video playing while sound on background music playing...
$(video).mouseleave(function(){ audioelement.play(); **something here pause youbevideo** }); is possible? keep version of youtube video because use fitvids resize videos .
thanks
pierre srry english...
here solution me, ravi.
so solution move youyube api script external js main html.
http://users.skynet.be/fc864408/version9.html
<body> <div class="tf_content" id="page4"> <div class="container"> <div class="vendor" id="video"> <div id="player"></div> </div> </div> </div> <!-- javascript --> <script> var tag = document.createelement('script'); tag.src = "https://www.youtube.com/iframe_api"; var firstscripttag = document.getelementsbytagname('script')[0]; firstscripttag.parentnode.insertbefore(tag, firstscripttag) var player; function onyoutubeiframeapiready() { player = new yt.player('player', { height: '420', width: '640', videoid: 'lvqziwpclxa?theme=light&color=white&autohide=0&autoplay=0&showinfo=0&rel=1&controls=1;', events: { 'onready': onplayerready, 'onstatechange': onplayerstatechange } }); } function onplayerready(event) { } var done = false; function onplayerstatechange(event) { if (event.data == yt.playerstate.playing ) { audioelement.volume=0; done = true; } } video = document.getelementbyid("video"); $(video).mouseleave(function(){ player.stopvideo() up(); }); $(".container").fitvids(); now works... video resizing according window.
just use (videoelementid).play() , (videoelementid).pause() play/pause video on mouse events. don't need play/pause audio , video separately.
regards, ravi
Comments
Post a Comment