在UIWebView中视频启动或停止时获取通知

Kru*_*shi 6 iphone mpmovieplayercontroller uiwebview

你好,我是目标新手 - c

我在同一个问题UIWebViewMPMoviePlayerController:我UIWebView有一个电影的HTML中(这是一个本地的HTML文件),我使用HTML5和用于视频的视频标签.

我希望在视频开始或停止时UIWebView收到通知....

我尝试过使用MPMoviePlayerPlaybackDidFinishNotification,但它没有开火......

我也试图让我的主UIViewController视图成为我自己的观点,拦截-didAddSubview:-willRemoveSubview:.但没有成功......

有没有人知道如何获得通知uiwebview

rob*_*off 19

你可以观察@"MPAVControllerPlaybackStateChangedNotification"(nil用于对象).此通知未记录,因此我不知道App Store是否会批准您的应用.

[[NSNotificationCenter defaultCenter] addObserver:self
    selector:@selector(playbackStateDidChange:)
    name:@"MPAVControllerPlaybackStateChangedNotification"
    object:nil];
Run Code Online (Sandbox Code Playgroud)

通知有钥匙MPAVControllerNewStateParameter在它的userInfo.播放开始前该值似乎为0,暂停时为1,正在播放时为2,拖动播放滑块时为3(暂时).

- (void)playbackStateDidChange:(NSNotification *)note
{
    NSLog(@"note.name=%@ state=%d", note.name, [[note.userInfo objectForKey:@"MPAVControllerNewStateParameter"] intValue]);
}
Run Code Online (Sandbox Code Playgroud)