YouTube playinline属性

时间:2015-03-01 09:53:46

标签: cordova youtube-api

window.player;
window.onYouTubeIframeAPIReady = function () {

  player = new YT.Player('player', {
    height: '200',
    width: '200',
    videoId: 'sdfsdfasd',
    playerVars: {'playsinline': 1},
    events: {
      'onReady': app.onPlayerReady,
      'onStateChange': app.onPlayerStateChange,
      'onError': app.onPlayerError
    }
  });

在我的Cordova iOS应用中,当播放器准备就绪时,我将YouTube iframe的playinline属性设置为1。但是,当我播放视频时,播放器全屏显示。 Google API群组中有一篇关于YouTube API的帖子,其中显示现在有playsinline属性,但它不起作用。

该属性在模拟器中工作正常,但它不适用于真实设备。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

当我在webViewDidFinishLoad中编辑源代码时,问题解决了。从下面

- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
    // Black base color for background matches the native apps
    theWebView.backgroundColor = [UIColor blackColor];
    return [super webViewDidFinishLoad:theWebView];
}

我添加了theWebView.allowsInlineMediaPlayback=YES;

- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
    // Black base color for background matches the native apps
    theWebView.backgroundColor = [UIColor blackColor];
    theWebView.allowsInlineMediaPlayback=YES; // <- added
    return [super webViewDidFinishLoad:theWebView];
}