Can I use it to play some youtube video?

Yes. UniWebView support playing youtube on web page. More than that, UniWebView is compatible with HTML 5 and javascript. That means videos embedded by HTML 5 or webpages containing HTML 5 elements will work correctly in UniWebView as well.

Have more questions? Submit a request

3 Comments

  • 0
    Avatar
    Ted Gamaya

    We are want to show some youtube videos inside our Unity game. On iOS's Safari, clicking an embedded youtube video on a web page will open the video in full screen, with iOS's MPMoviePlayerController's tool bar. How do we do this using UniWebView?

  • 0
    Avatar
    Fredrick Bäcker

    Same question here. 

    I load a simple html page

    _webView = GetComponent<UniWebView>();
    _webView.OnLoadComplete += OnLoadComplete;
    _webView.OnEvalJavaScriptFinished += OnEvalJavaScriptFinished;
    _webView.insets = new UniWebViewEdgeInsets(5,5,5,5);
    _webView.url = "https://f97a80de.ngrok.io/web.html";
    _webView.HideToolBar (false);

     

    The page shows with a video. It doesn't autostart (as it does when I use a normal web browser). When I click on the play icon it just turns black.

     

    HTML page

     

    <html>

    <body>
    <iframe id="ytplayer" type="text/html" width="640" height="390"
    src="https://www.youtube.com/embed/IYuyWeIuQk4?autoplay=1&modestbranding=1"
    frameborder="0"></iframe>
    </body>

  • 0
    Avatar
    Fredrick Bäcker

    Got it to work

     

    <html>
    <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style>
    body,html {
    padding: 0px;
    margin: 0px;
    }
    </style>
    <script type="text/javascript">

    function onLoad(){
    function onResize(e){
    var w = window.innerWidth;
    var h = w * 0.5625;
    var m = document.getElementById("main");
    m.setAttribute("style","width:"+w+"px;height:"+h+"px;");

    window.location = "uniwebview://resize?width="+w+"&height="+h;
    }

    window.addEventListener("resize", onResize);
    onResize(null);

    };

    </script>
    </head>
    <body onload="onLoad()">
    <div id="main">
    <iframe id="ytplayer" type="text/html" width="100%" height="100%"
    src="https://www.youtube.com/embed/GstrrdlMJdk?autoplay=1&modestbranding=1"
    frameborder="0"></iframe>
    </div>
    </body>
    </html>

     

Please sign in to leave a comment.
Powered by Zendesk