dvkellerman
dvkellerman

Reputation: 47

UIWebView embedded video fullscreen issue

I'm using ifame api to embed youtube video into UIWebView. I have a problem when closing the fullscreen mode - the player is translated to wrong position. Seems like the hide animation has some bug. The only solution i found is to place the UIWebView in top-left corner. I created a github repo with a simple project to demonstrate this issue. https://github.com/demonoid67/youtube-video-sample . Can someone help me? Thanks in advangtage!

Upvotes: 2

Views: 940

Answers (1)

Adela Toderici
Adela Toderici

Reputation: 1112

                NSString*  embedHTML = [NSString stringWithFormat:@"\
                                    <html>\
                                    <body style='margin:0px;padding:0px;'>\
                                    <script type='text/javascript' src='http://www.youtube.com/iframe_api'></script>\
                                    <script type='text/javascript'>\
                                    function onYouTubeIframeAPIReady()\
                                    {\
                                    ytplayer=new YT.Player('playerId',{events:{onReady:onPlayerReady}})\
                                    }\
                                    function onPlayerReady(a)\
                                    { \
                                    a.target.playVideo(); \
                                    }\
                                    </script>\
                                    <iframe id='playerId' type='text/html' width='%f' height='%f' src='http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=1&autoplay=1&controls=1' frameborder='0'>\
                                    </body>\
                                    </html>", youtubeWebView.frame.size.width, youtubeWebView.frame.size.height, selectedVideoModel.youtubeId];

            [youtubeWebView setAllowsInlineMediaPlayback:YES];
            [youtubeWebView setMediaPlaybackRequiresUserAction:NO];
            [youtubeWebView loadHTMLString:embedHTML baseURL: nil]; 

Maybe this will help you.

Upvotes: 3

Related Questions