我正在使用它来播放本地 .mov 文件
NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]
pathForResource:@"MOVIE" ofType:@"mov"]];
moviePlayer =
[[MPMoviePlayerController alloc]
initWithContentURL:url];
[moviePlayer setControlStyle:MPMovieControlStyleNone];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector( moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayer];
[moviePlayer setScalingMode:MPMovieScalingModeAspectFill];
[moviePlayer setFullscreen:FALSE];
//---play partial screen---
moviePlayer.view.frame = CGRectMake(0, 0, 320, 240);
moviePlayer.shouldAutoplay = YES;
[self.view addSubview:moviePlayer.view];
[moviePlayer play];
我想从 url 预加载视频并将其保存到驱动器,以便在播放时没有网络延迟。如何从 url 保存文件,然后将其加载到 mpmovieplayer。
好像应该是这样的……
NSString *stringURL = @"url to file";
NSURL *url = [NSURL URLWithString:stringURL];
NSData *urlData = [NSData dataWithContentsOfURL:url];
但如果是这种情况,我不知道如何用数据初始化它。