美文网首页
通过AVPlayerItem来拦截webview视频播放地址

通过AVPlayerItem来拦截webview视频播放地址

作者: 躱喵喵 | 来源:发表于2018-10-19 13:16 被阅读0次

不多说直接上代码。

新建一个通知

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(notification:) name:AVPlayerItemTimeJumpedNotification object:nil];

- (void)notification:(NSNotification*)info

{

    id obj = info.object;    

AVPlayerItem*item = obj;

    AVURLAsset*asset =item.asset;

    NSLog(@"%@", asset.URL);//这里就会log出一个视频的播放地址

//    [self plauerViewWithUrl:subString];

}

//下面是webview

 [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"视频"]]];

    self.webView.allowsInlineMediaPlayback=YES;

    self.webView.mediaPlaybackRequiresUserAction = NO;//打开自动播放视频

相关文章

网友评论

      本文标题:通过AVPlayerItem来拦截webview视频播放地址

      本文链接:https://www.haomeiwen.com/subject/xbnvmxtx.html