YouTube embeds in UIWebViews no longer working in iOS

后端 未结 2 1320
说谎
说谎 2020-12-28 22:52

I\'ve had an app out for a while which uses UIWebViews to display YouTube videos on certain views. Today, without any changes to the code, my users started comp

2条回答
  •  礼貌的吻别
    2020-12-28 23:02

    Someone found a workaround here, to an extent. Not sure how to mark an answer like that, but I'll copy it over to here for convenience.

    Essentially the issue seems to relate to a change in implementation of the playsinline parameter on YouTube's side. It doesn't matter what value you provide, or whether you use the default, but it seems to break every Youtube video embedded in this way.

    The solution seems to be adding the following line before you call [myWebView loadHTMLString:string]:

    [myWebView setMediaPlaybackRequiresUserAction:NO];
    

    I have no idea why this fixes it, but many thanks to Kyokook Hwang for providing that answer so quickly. It worked for me, and it seemed to work for many others too.

提交回复
热议问题