2014-02-11 69 views
0

我必須從服務器流式傳輸視頻(.mov)。 我使用一個UIWebView和它的作品很好,但委託方法在webview或MPMoviePlayerViewController中的iOS流式視頻

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error; 

總是調用,而不是

- (void)webViewDidFinishLoad:(UIWebView *)webView; 

我打印錯誤:

Error Domain=WebKitErrorDomain Code=204 "Plug-in handled load" (...) 

後來我決定用MPMoviePlayerViewController代替。 它看起來更慢! 這是一個很好的練習使用UIWebView流式視頻?我該如何解決我的錯誤? 我的目的是否有任何解決方案?

預先感謝您

回答

0

同樣,如果你決定使用MPMoviePlayerViewController。試試這個......

-(IBAction)btnVideoClicked:(id)sender 
{ 
    @try 
    { 
     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init]; 
     GetVideos *obj_video = [arrVideos objectAtIndex:[sender tag]]; 
     MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL URLWithString:obj_video.VideoPath]]; 
     [moviePlayerViewController.moviePlayer setControlStyle:MPMovieControlStyleFullscreen]; 
     [moviePlayerViewController.moviePlayer setShouldAutoplay:YES]; 
     [moviePlayerViewController.moviePlayer setFullscreen:NO animated:YES]; 
     [moviePlayerViewController setModalTransitionStyle:UIModalTransitionStyleCoverVertical]; 
     [moviePlayerViewController.moviePlayer setScalingMode:MPMovieScalingModeNone]; 
     [moviePlayerViewController.moviePlayer setUseApplicationAudioSession:NO]; 
     // Register to receive a notification when the movie has finished playing. 
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlaybackStateDidChange:)  name:MPMoviePlayerPlaybackStateDidChangeNotification object:moviePlayerViewController]; 
     // Register to receive a notification when the movie has finished playing. 
     [[NSNotificationCenter defaultCenter] addObserver:self  selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification  object:moviePlayerViewController]; 
     [self presentMoviePlayerViewControllerAnimated:moviePlayerViewController]; 
     moviePlayerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming; 
     [moviePlayerViewController release]; 
     [pool release]; 
    } 
    @catch (NSException *exception) { 
     // throws exception 
    } 
} 
相關問題