全屏播放youtube视频?

时间:2021-04-12 18:57:26

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:

我正在为iPad应用程序开发并尝试使用以下代码播放YouTube视频:

        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.

在iphone应用程序中使用时,代码可以正常工作(即,您可以触摸webview并开始全屏播放YouTube视频。)但是,当在iPad中使用时,在点击Web视图时,它会开始在Web视图中播放视频并显示进入全屏的选项,而我想从头开始全屏播放,就像在iPhone中一样。

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

任何有想法的人或以前做过的人都请帮忙。

Thanks,

谢谢,

Madhup

Madhup

1 个解决方案

#1


0  

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.

我所做的是在webviews上添加了相同大小的按钮,当它被触摸时,我用相同的html打开一个不同的webview,并以编程方式在此Web视图上传递触摸事件。所以它对我来说就像我想要的那样。

#1


0  

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.

我所做的是在webviews上添加了相同大小的按钮,当它被触摸时,我用相同的html打开一个不同的webview,并以编程方式在此Web视图上传递触摸事件。所以它对我来说就像我想要的那样。