2016-07-02 116 views
0

我正在從我的帳戶播放列表中播放視頻。但是一些視頻在webview中沒有顯示錯誤。Youtube播放視頻:與此視頻關聯的youtube帳戶已被終止

- (void)playVideoWithId:(NSString *)videoId { 

    NSString *youTubeVideoHTML = @"<html><head><style>body{margin:0px 0px 0px 0px;}</style></head> <body> <div id=\"player\"></div> <script> var tag = document.createElement('script'); tag.src = 'http://www.youtube.com/player_api'; var firstScriptTag = document.getElementsByTagName('script')[0]; firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); var player; function onYouTubePlayerAPIReady() { player = new YT.Player('player', { width:'768', height:'1024', videoId:'sLVGweQU7rQ', events: { 'onReady': onPlayerReady } }); } function onPlayerReady(event) { event.target.playVideo(); } </script> </body> </html>"; 

    NSString *html = [NSString stringWithFormat:youTubeVideoHTML, videoId]; 

    UIWebView *videoView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    videoView.backgroundColor = [UIColor clearColor]; 
    videoView.opaque = NO; 
    //videoView.delegate = self; 
    [self.view addSubview:videoView]; 

    videoView.mediaPlaybackRequiresUserAction = NO; 

    [videoView loadHTMLString:youTubeVideoHTML baseURL:[[NSBundle mainBundle] resourceURL]]; 
} 

錯誤圖像

enter image description here

我怎樣才能解決這個問題。

+0

您可能希望在'youTubeVideoHTML'中將'videoId:'sLVGweQU7rQ''替換爲'videoId:'%@''。這樣該參數將在HTML字符串中正確使用。我認爲這將使一切按預期工作。 –

回答

0

當帳戶被終止或關閉時,該帳戶上傳的所有視頻都將從YouTube服務器中刪除。您無法觀看此視頻。