从 UIWebView 中的电影播放器获取通知
我的应用程序通过在 UIWebView 中加载 URL 来流式传输 YouTube 视频:
NSString *videoURLStr = [NSString stringWithFormat:@"http://www.youtube.com/embed/%@?autoplay=1", videoId];
NSURL* videoURL = [NSURL URLWithString:videoURLStr];
[movieView loadRequest:[NSURLRequest requestWithURL:videoURL]];
这非常有效,只是我的应用程序不知道电影播放器中发生了什么。例如,我希望能够在电影播放器窗口打开时更改我的视图。我还想知道它何时关闭并且控制权何时返回到我的应用程序。
我已将视图设置为 UIWebView 的委托,并实现了
- (void)webViewDidFinishLoad:(UIWebView *)webView
UIWebView 加载视频的包装器代码后调用此方法,但电影播放器窗口尚不可见。似乎只有当电影开始播放时,即在缓冲了足够的电影之后,电影播放器窗口才变得可见。
我所要求的可能是不可能的,但如果有人有任何想法,我很乐意听到他们。
谢谢。
My application is streaming YouTube videos by loading a URL in a UIWebView:
NSString *videoURLStr = [NSString stringWithFormat:@"http://www.youtube.com/embed/%@?autoplay=1", videoId];
NSURL* videoURL = [NSURL URLWithString:videoURLStr];
[movieView loadRequest:[NSURLRequest requestWithURL:videoURL]];
This works great, except that my application has no awareness of what's going on in the movie player. For instance, I'd like to be able to make changes to my view when the movie player window opens. I'd also like to know when it closes and control returns to my application.
I've set my view as the delegate to the UIWebView, and implemented
- (void)webViewDidFinishLoad:(UIWebView *)webView
This is called after the UIWebView has loaded the wrapper code for the video, but the movie player window is not yet visible. It would seem that the movie player window becomes visible only when the movie begins playing, i.e. after enough of the movie has been buffered.
What I'm asking for may not be possible, but if anyone has any ideas I'd love to hear them.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您打算走这条路线,那么您将需要使用 youtube javascript api
http ://code.google.com/apis/youtube/js_api_reference.html#EventHandlers
if you are going to go this route then you will need to use the youtube javascript api
http://code.google.com/apis/youtube/js_api_reference.html#EventHandlers