Search code examples
iphoneipadyoutube-apiembedded-video

Play youtube video in full screen?


First of all sorry, If somebody finds this question is repeated (haven't found any by myself).

I am developing for an iPad application and trying to play youtube videos using this code:

        NSString *embedHTML = @"\
        <html><head>\
        <style type=\"text/css\">\
        body {\
        background-color: transparent;\
        color: white;\
        }\
        </style>\
        </head><body style=\"margin:0\">\
        <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
        width=\"%0.0f\" height=\"%0.0f\"></embed>\
        </body></html>";
        NSString *html = [NSString stringWithFormat:embedHTML, youTubeUrl, 142.0, 129.5];
        [wbView loadHTMLString:html baseURL:nil];

The code works fine when used in an iphone application (i.e. you touch on the webview and it starts playing the youtube video in fullscreen.) But when used in the iPad, on clicking the web view it starts playing the video in the web view itself and shows options to go to full screen, while I want to start the playback in the full screen from the beginning, like it does in the iPhone.

Anybody having some ideas or people who have done it before please help.

Thanks,

Madhup


Solution

  • I got a solution to this but thats just a workaround only. Hopefully anybody gives a better solution.

    What I did is I added buttons of same size on the webviews and when its touched I open a different webview with the same html and pass a touch event on this web view programmatically. So it works for me like I wanted.