开发者

Getting notifications from movie player in UIWebView

开发者 https://www.devze.com 2023-01-20 21:32 出处:网络
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];

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 *)we开发者_如何转开发bView

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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消