javascript - YouTube Iframe API on Iphone without fullscreen - Stack Overflow

I have a web application which uses YouTube Iframe API to sync lyrics and chords with YouTube songs. It

I have a web application which uses YouTube Iframe API to sync lyrics and chords with YouTube songs. It is essential for us that the embedded video plays inline without fullscreen. Otherwise users can not see the lyrics and the chords on the page and the app would be meaningless.

Here is the demo.

We have get 50% of our traffic from iphones, however iphones play youtube videos always fullscreen.

Here is the code to embed the video

var player;

function onYouTubeIframeAPIReady() {
  player = new YT.Player('player', {
    height: '390',
    width: '640',
    videoId: $("#ytid").attr("value"),
    playerVars: {'theme':'light','color':'white','modestbranding':1,'rel':0},
    events: {
      'onReady': onPlayerReady,
      'onStateChange': onPlayerStateChange
    }
  });

Looking for a solution on the web, we have tried some fixes but none of them work on iphone. We are also ready to develop a Swift application if we believe it would work. However web search also suggests the opposite.

  1. Is there a solid workaround to play YouTube Iframe API videos inline?
  2. Can we solve our problem by developing a native IOS application?

I have a web application which uses YouTube Iframe API to sync lyrics and chords with YouTube songs. It is essential for us that the embedded video plays inline without fullscreen. Otherwise users can not see the lyrics and the chords on the page and the app would be meaningless.

Here is the demo.

We have get 50% of our traffic from iphones, however iphones play youtube videos always fullscreen.

Here is the code to embed the video

var player;

function onYouTubeIframeAPIReady() {
  player = new YT.Player('player', {
    height: '390',
    width: '640',
    videoId: $("#ytid").attr("value"),
    playerVars: {'theme':'light','color':'white','modestbranding':1,'rel':0},
    events: {
      'onReady': onPlayerReady,
      'onStateChange': onPlayerStateChange
    }
  });

Looking for a solution on the web, we have tried some fixes but none of them work on iphone. We are also ready to develop a Swift application if we believe it would work. However web search also suggests the opposite.

  1. Is there a solid workaround to play YouTube Iframe API videos inline?
  2. Can we solve our problem by developing a native IOS application?
Share Improve this question asked Mar 16, 2016 at 18:14 GirayGiray 1051 silver badge9 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

Adding the parameter 'playsinline':'1' to the playerVars worked for me. I don't know whether this is true for web as well, I am working from a WebView in a React Native app.

var player;

function onYouTubeIframeAPIReady() {
    player = new YT.Player('player', {
    height: '390',
    width: '640',
    videoId: $("#ytid").attr("value"),
    playerVars: {'playsinline':'1', 'theme':'light','color':'white','modestbranding':1,'rel':0},
    events: {
        'onReady': onPlayerReady,
        'onStateChange': onPlayerStateChange
    }
});

Broadly speaking: No, Safari on the iPhone will always play videos fullscreen

The iPad does support inline video playback.

If you had your own iOS application, obviously you could have more control over the video playback. Looking at your website, having an app would certainly allow you to have better control over the autoscrolling etc as it does open up a whole world of abilities (and plexity!).

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744227075a4564060.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信