4
的網址有沒有什麼辦法讓正在播放video.I的鏈接我裝m.youtube.com。對於一些視頻它甚至沒有進入代表。我嘗試使用NStimer。但對於某些視頻,它不是被點擊的網址如何獲得當前播放的視頻中的UIWebView
的網址有沒有什麼辦法讓正在播放video.I的鏈接我裝m.youtube.com。對於一些視頻它甚至沒有進入代表。我嘗試使用NStimer。但對於某些視頻,它不是被點擊的網址如何獲得當前播放的視頻中的UIWebView
通過偵聽AVPlayerItemBecameCurrentNotification
通知,您可能會採取這種做法。當UIWebView顯示媒體播放器時觸發此通知,併發送一個AVPlayerItem
作爲通知的對象。
例如:
[[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];
NSString *path = [url absoluteString];
}
這適用於任何視頻(音頻)。然而,我注意到你提到的YouTube - 值得指出的是蘋果將拒絕你的應用程序,如果它有能力下載YouTube視頻在所有,因爲它不符合YouTube's Terms of Service。
謝謝,它的工作。即使我無法獲得與視頻對應的當前網址。是否有任何方法? – Jeff 2014-10-02 06:07:28
@Jeff你是什麼意思?我上面的示例代碼顯示獲取URL作爲NSURL和NSString。這是正在播放的視頻的網址。 – ttarik 2014-10-02 06:10:45
我正在編碼的url.I問關於視頻的youtube鏈接 – Jeff 2014-10-02 06:15:37