我的电影播放器正在播放但不播放任何视频。它只播放声音。
我的代码如下:
self.moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:nil];
self.moviePlayer.view.frame=CGRectMake(10, (self.view.frame.size.height-200-64)/2, 300, 200);
[self.moviePlayer setControlStyle:MPMovieControlStyleDefault];
[self.moviePlayer setShouldAutoplay:YES];
self.moviePlayer.allowsAirPlay = YES;
self.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
self.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
self.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
[self.moviePlayer setContentURL:[NSURL URLWithString:AttachmentUrl]];
[self.view addSubview:self.moviePlayer.view];
self.moviePlayer.fullscreen=YES;
[self.moviePlayer prepareToPlay];
[self.moviePlayer play];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(movieloadStateHandler:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:nil];
请建议我需要做什么。
答案 0 :(得分:1)
我的经验是,最好使用:MPMoviePlayerViewController
例如:
MPMoviePlayerViewController *mvPlayerController = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL URLWithString:AttachmentUrl]];