我在popcorn webmaker中得到这个错误
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('https://www.youtube.com') does not match the recipient window's origin ('http://localhost:8888').
我无法在chrome浏览器中播放youtube视频。在mozilla和safari中,它工作得很好。
有谁能帮我解决这个问题吗?
这是我的iframe代码。我正在使用youtube的最新api,即:
https://www.youtube.com/iframe_api
我的Iframe代码如下:-
<iframe frameborder="0" allowfullscreen="1" title="YouTube video player" width="100%" height="100%" src="https://www.youtube.com/embed/0Fegb4Ew8SM?butteruid=1437727498131&rel=0&modestbranding=1&iv_load_policy=3&disablekb=1&showinfo=0&origin=http%3A%2F%2Flocalhost%3A8888&controls=0&wmode=opaque&html5=1&enablejsapi=1" id="widget4"></iframe>
视频加载1 - 2秒后进入无限等待状态
要了解更多详情,请访问:54.186.240.149:8888
解决方案:-
// This function needs duration and first play to be ready.
function onFirstPlay() {
removeYouTubeEvent( "play", onFirstPlay );
if ( player.getCurrentTime() === 0 ) {
setTimeout( onFirstPlay, 0 );
return;
}
addYouTubeEvent( "pause", onFirstPause );
player.pauseVideo();
player.seekTo( 0 );
}
它最初是
// This function needs duration and first play to be ready.
function onFirstPlay() {
removeYouTubeEvent( "play", onFirstPlay );
if ( player.getCurrentTime() === 0 ) {
setTimeout( onFirstPlay, 0 );
return;
}
addYouTubeEvent( "pause", onFirstPause );
player.seekTo( 0 );
player.pauseVideo();
}