div를 마우스로 가리키면 YouTube iframe을 삽입하는 기능을 만들고 있습니다. when the user leaves div the video is paused.
Everythings은 잘 작동하지만 사용자가 div를 떠날 때 동영상이 일시 중지되지 않습니다.마우스를 올려 놓으면 YouTube 비디오가 일시 중지됩니다.
바이올린 : http://jsfiddle.net/508oknm7/20/
어떤 아이디어? 고맙습니다!
var tag = document.createElement('script'),
firstScriptTag = document.getElementsByTagName('script')[0];
tag.src = "https://www.youtube.com/player_api";
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
$(".video_wrap").on({
mouseenter: function() {
player = new YT.Player($(this).attr('id'), {
height: '240',
width: '320',
videoId: 'wJnnT1SGEsc',
playerVars: {
wmode: "transparent",
controls: 0,
showinfo: 0,
rel: 0,
modestbranding: 1,
iv_load_policy: 3 //anottations
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
function onPlayerReady(event) {
event.target.playVideo();
}
},
mouseleave: function() {
player.pauseVideo();
}
});
Fiddle : http://jsfiddle.net/508oknm7/20/ @Etai –
@rexhin 답변을 올렸습니다. 건배. – Etai
감사합니다. 여러 div는 어떻게됩니까? 하나 이상의 @Etai와 함께 작업해야합니다. –