Youtube video autoplay inside UIWebview

前端 未结 4 982
广开言路
广开言路 2020-12-09 14:03

I found many questions in this forum regarding embedding youtube video and autoplay, but none of them cleared all my doubts.

I found two methods to embed youtube vid

相关标签:
4条回答
  • 2020-12-09 14:29

    You can also use this trick from the Saurabh Wadhwa Answer that fire the endActionsForControlEvents:UIControlEventTouchUpInside after UIWebView finished download

    0 讨论(0)
  • 2020-12-09 14:32

    Q. If I am correct that (2) is recommended

    A. Yes (2) method is for i-devices where no flash support.

    Q. Autoplay with (2) is not possible.

    A. No autoplay is not possible as of now.

    Update: I am able to autoplay youtube video by using Youtube JS APIs see https://developers.google.com/youtube/js_api_reference

    Just call playVideo from onPlayerReady

    function onPlayerReady(event) {
                    event.target.playVideo();                    
                }
    
    0 讨论(0)
  • 2020-12-09 14:50

    Autoplay is possible by issuing:

    webView.mediaPlaybackRequiresUserAction=FALSE;
    
    0 讨论(0)
  • 2020-12-09 14:51

    I solved the problem by adding the follow code:

    webview.mediaPlaybackRequiresUserAction=NO;
    webview.allowsInlineMediaPlayback=YES;
    
    0 讨论(0)
提交回复
热议问题