1

I have an app that supports only portrait but I have some embedded youtube videos that should have the possibility to play also in landscape, I can't find a solution for this.. This is the code for the webView where the YT video is loaded:

ytView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,170)];
        ytView.delegate = self;
        [ytView setAllowsInlineMediaPlayback:YES];
        [ytView setMediaPlaybackRequiresUserAction:NO];

        [_scrollingView addSubview:ytView];

        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='%d' src='http://www.youtube.com/embed/%@?enablejsapi=1&rel=0&playsinline=1&autoplay=1' frameborder='0'>\
                               </body>\
                               </html>", self.view.frame.size.width, 170, needle];
        [ytView loadHTMLString:embedHTML baseURL:[[NSBundle mainBundle] resourceURL]];

Does anyone have a solution for this problem?

LS_
  • 6,763
  • 9
  • 52
  • 88
  • You could consider using the native MPMoviePlayerController to play the videos instead... but that would be against the YouTube ToS. - You would need an YouTube video link extrater for this. –  Jun 04 '15 at 13:01

0 Answers0