Search code examples
iosuiwebviewyoutubemedia-playermpmediaplayercontroller

How to access ios media player instance when youtube video is playing


I used below function for play youtube videos in iPhone using UIWebView

      - (void)embedYouTube {

       videoHTML = [NSString stringWithFormat:@"\
             <html>\
             <head>\
             <style type=\"text/css\">\
             iframe {position:absolute; top:50%%; margin-top:-130px;}\
             body {background-color:#000; margin:0;}\
             </style>\
             </head>\
             <body>\
             <iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/xxxxxxxxxxxxx\" frameborder=\"0\" allowfullscreen></iframe>\
             </body>\
             </html>"];

        [videoView loadHTMLString:videoHTML baseURL:nil];
    }

By this method video will play in the iOS media player. I wanted to hide controllers automatically, when the video is playing. Problem is how to access the media player instance.


Solution

  • I think you can try Subview concept, to access MoviePlayercontroller. Please refer this article here.