全屏播放 YouTube 视频?
首先抱歉,如果有人发现这个问题重复了(我自己没有发现)。
我正在开发一个 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];
该代码在 iphone 应用程序中使用时工作正常(即您触摸 webview,它开始全屏播放 youtube 视频。)但是当在iPad,点击网页视图后,它会开始在网页视图本身中播放视频,并显示进入全屏的选项,而我想从头开始全屏播放,就像在 iPhone 中一样。
任何有想法或以前做过的人请帮忙。
谢谢,
马杜普
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我对此有一个解决方案,但这只是一个解决方法。希望有人给出更好的解决方案。
我所做的是在 Web 视图上添加相同大小的按钮,当触摸它时,我打开具有相同 html 的不同 Web 视图,并以编程方式在该 Web 视图上传递触摸事件。所以它对我有用,就像我想要的那样。
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.