ios - 识别在iOS的WebView中播放的youtube视频网址?

标签 ios objective-c video youtube uiwebview

我有一个webview控件,并要求在YouTube中进行一些搜索。
有很多结果视频。
用户单击其中之一。
如何获得视频网址播放?

最佳答案

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(playerItemBecameCurrent:)
                                             name:@"AVPlayerItemBecameCurrentNotification"
                                           object:nil];


- (void)playerItemBecameCurrent:(NSNotification*)notification 
{
        AVPlayerItem *playerItem = [notification object];
        if(playerItem == nil) return;

        // Break down the AVPlayerItem to get to the path
        AVURLAsset *asset = (AVURLAsset*)[playerItem asset];
        NSURL *url = [asset URL]; // this is URL you need
}

关于ios - 识别在iOS的WebView中播放的youtube视频网址?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38117678/

相关文章:

iphone - 排序 2D NSMutableArray

iphone - 想要缩放图像的位置

video - 将透明视频叠加在其他视频之上

java - 可以在 Java 中绘制 YCbCr 吗?

objective-c - 在 Block 中释放 View Controller 的位置

objective-c - 如果将自动释放对象标记为自动释放会发生什么

ios - 在标签栏 Controller 中的推送 View Controller 中显示工具栏

video - 哪些视频编解码器适用于 Google Chromebook

ios - 将 UITableView 中的选定行保存到 NSUserDefaults

ios - 如何设置自定义 X 轴标签间隔?