Youtube video autoplay on iPhone's Safari or UIWebView

前端 未结 5 1694
遇见更好的自我
遇见更好的自我 2020-12-02 19:35

Is it possible to get a youtube video to autoplay on Safari and/or UIWebView? I\'ve seen this done in an iPhone app, the tableview displays cells that do not have Youtube pr

5条回答
  •  臣服心动
    2020-12-02 19:57

    If you create your own html file that uses an iframe and then you load the webview to that then you can just put in the command

    webView.mediaPlaybackRequiresUserAction=FALSE; 
    

    and the video will autoplay as long as you have already had your youtube video in the html already start the video. The html file can be found on the source of the following page. view-source:http://tylerbiscoe.com/vb/iphone_player.html. If you copy and paste that into the browser you can see what the iframe page will look like. Then use the webView to load your youTube page and then use the command above to get the quicktime player that gets called by ios to auto play after the webview is done loading. The page above has three videos already included and all three will play in series to one another.

提交回复
热议问题