我必须从服务器流式传输视频(.mov)。 我使用UIWebView,但是它的工作方式很好,但委托方法
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error;
总是调用
- (void)webViewDidFinishLoad:(UIWebView *)webView;
我打印错误:
Error Domain=WebKitErrorDomain Code=204 "Plug-in handled load" (...)
之后我决定改用MPMoviePlayerViewController
。
它看起来更慢!
使用UIWebView流式传输视频是一种很好的做法吗?我该如何修复错误?
我的目的是否有任何紧凑的解决方案?
提前谢谢
答案 0 :(得分: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
}
}