黑屏视频播放网址来自服务器端

时间:2014-04-23 05:44:17

标签: ios objective-c video

  1. NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask,YES);     NSString * documentsDirectory = [paths objectAtIndex:0];     NSString * pathVideo = [documentsDirectory stringByAppendingPathComponent:@" MyVideo.mp4"];
        NSURL * movieURL = [NSURL fileURLWithPath:pathVideo];     self.movi​​ePlayer = [[MPMoviePlayerController alloc] init];     [self.movi​​ePlayer setShouldAutoplay:YES];     [self.movi​​ePlayer setContentURL:movieURL.absoluteURL];     [self.movi​​ePlayer setMovieSourceType:MPMovieSourceTypeFile];     [self.movi​​ePlayer setControlStyle:MPMovieControlModeDefault];     [self.movi​​ePlayer setFullscreen:NO];     [self.movi​​ePlayer setScalingMode:MPMovieScalingModeNone];      self.movi​​ePlayer.view.frame = CGRectMake(40,40,240,350);        [self.view addSubview:self.movi​​ePlayer.view];     [self.movi​​ePlayer prepareToPlay];     [self.movi​​ePlayer play];

1 个答案:

答案 0 :(得分:1)

  

[self.view addSubview:self.movi​​ePlayer.view];在

之前添加此内容
[self.moviePlayer prepareToPlay];
[self.moviePlayer play];

这一行。

FYI。这个玩家可以在模拟器中玩。