爆米花网络制作者的Youtube视频无法加载,无限缓冲视频

时间:2015-07-24 08:54:02

标签: node.js youtube-api popcornjs

我在爆米花网络制作者中遇到此错误

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中播放你管视频。在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&amp;rel=0&amp;modestbranding=1&amp;iv_load_policy=3&amp;disablekb=1&amp;showinfo=0&amp;origin=http%3A%2F%2Flocalhost%3A8888&amp;controls=0&amp;wmode=opaque&amp;html5=1&amp;enablejsapi=1" id="widget4"></iframe>

视频加载1或2秒然后进入无限等待状态。

您可以访问更多详细信息: 54.186.240.149:8888

请检查chrome。

1 个答案:

答案 0 :(得分: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.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();
}