你好,我是目标 - c 的新手
我的 UIWebView
和 MPMoviePlayerController
遇到问题:我的 UIWebView
在 html 中有一个电影(它是一个本地 html 文件) ),我正在使用 html5 和视频的视频标签。
我希望在 UIWebView
中视频开始或停止时收到通知....
我尝试使用MPMoviePlayerPlaybackDidFinishNotification
,但它不触发...
我还尝试使我的主 UIViewController
View 成为我自己的 View ,并拦截 -didAddSubview:
和 -willRemoveSubview:
.但没有成功...
有人知道如何从uiwebview
获取通知吗??
最佳答案
您可以观察@"MPAVControllerPlaybackStateChangedNotification"
(对对象使用nil
)。此通知未记录在案,因此我不知道 App Store 是否会批准您的应用。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playbackStateDidChange:)
name:@"MPAVControllerPlaybackStateChangedNotification"
object:nil];
该通知的 userInfo
中有关键的 MPAVControllerNewStateParameter
。播放开始前该值似乎为 0,暂停时为 1,播放时为 2,拖动播放 slider 时为 3(暂时)。
- (void)playbackStateDidChange:(NSNotification *)note
{
NSLog(@"note.name=%@ state=%d", note.name, [[note.userInfo objectForKey:@"MPAVControllerNewStateParameter"] intValue]);
}
关于iphone - 当 UIWebView 中视频开始或停止时获取通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8253111/