如何从 Internet URL
或 本地文件
播放 .mp4 或 .mov 视频> 在 iOS 中?
如何在 Collection View Controller 中添加多个视频?
最佳答案
试试这个(MPMoviePlayerController):
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pathVideo = [documentsDirectory stringByAppendingPathComponent:@"MyVideo.mp4"];
NSURL *movieURL = [NSURL fileURLWithPath:pathVideo];
self.moviePlayer = [[MPMoviePlayerController alloc] init];
[self.moviePlayer setShouldAutoplay:YES];
[self.moviePlayer setContentURL:movieURL.absoluteURL];
[self.moviePlayer setMovieSourceType:MPMovieSourceTypeFile];
[self.moviePlayer setControlStyle:MPMovieControlModeDefault];
[self.moviePlayer setFullscreen:NO];
[self.moviePlayer setScalingMode:MPMovieScalingModeNone];
self.moviePlayer.view.frame = CGRectMake(40, 40, 240, 350);
[self.view addSubview:self.moviePlayer.view];
[self.moviePlayer prepareToPlay];
[self.moviePlayer play];
关于ios - 从 Internet URL 或 iOS 中的本地文件播放 .mp4 或 .mov 视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23512106/