我无法在本地播放视频。应用程序崩溃而不在控制台中显示任何错误消息。
代码如下......
// Player..
NSURL* videoURL = [NSURL fileURLWithPath:videoPath];
self.mpPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[self.mpPlayer prepareToPlay];
[self.mpPlayer play];
//For viewing partially.....
[self.mpPlayer.view setFrame:CGRectMake(0, 0, imageWidth, imageHeight)];
[self.mpPlayer.view setCenter:CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2)];
self.mpPlayer.view.backgroundColor = [UIColor grayColor];
self.mpPlayer.repeatMode = MPMovieRepeatModeOne;
self.mpPlayer.fullscreen = NO;
self.mpPlayer.movieSourceType = MPMovieSourceTypeFile;
[self.mpPlayer setControlStyle:MPMovieControlStyleNone];
self.mpPlayer.scalingMode = MPMovieScalingModeAspectFit;
[self addSubview:self.mpPlayer.view];
// Webview
NSURL* videoURL = [NSURL fileURLWithPath:videoPath];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:videoURL];
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, imageWidth, imageHeight)];
[webView setCenter:CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2)];
[webView loadRequest:request];
请告诉我,如果我做错了代码。
此致
答案 0 :(得分:0)
尝试这样的事情:
NSURL* videoURL = [NSURL fileURLWithPath:videoPath];
self.mpPlayer = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];
[self.mpPlayer.view setFrame:CGRectMake(0, 0, imageWidth, imageHeight)];
[self.mpPlayer.view setCenter:CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2)];
self.mpPlayer.view.backgroundColor = [UIColor grayColor];
self.mpPlayer.repeatMode = MPMovieRepeatModeOne;
self.mpPlayer.fullscreen = NO;
self.mpPlayer.movieSourceType = MPMovieSourceTypeFile;
[self.mpPlayer setControlStyle:MPMovieControlStyleNone];
self.mpPlayer.scalingMode = MPMovieScalingModeAspectFit;
[self addSubview:self.mpPlayer.view];
[self.mpPlayer play];
答案 1 :(得分:0)
问题已解决,实际上是由于异常断点。我删除了它,它现在正在工作。