在iphone中以编程方式从缓存播放视频

在iphone中以编程方式从缓存播放视频,iphone,caching,mpmovieplayercontroller,mpmovieplayer,Iphone,Caching,Mpmovieplayercontroller,Mpmovieplayer,我正在开发一个iPhone应用程序,在这个应用程序中,我将把来自URL的流视频直接存储到本地缓存中,现在我需要在电影播放器中播放视频,同时在缓存中下载视频。我遵循了这一点,但我不能做到准确。我可以在缓存中下载视频,但无法从缓存中播放视频。那么,我如何在下载时播放它呢?只要将您的web url更改为本地路径url 请尝试此代码 NSBundle *bundle = [NSBundle mainBundle]; NSString *moviePath = [bundle pathForRes

我正在开发一个iPhone应用程序,在这个应用程序中,我将把来自URL的流视频直接存储到本地缓存中,现在我需要在电影播放器中播放视频,同时在缓存中下载视频。我遵循了这一点,但我不能做到准确。我可以在缓存中下载视频,但无法从缓存中播放视频。那么,我如何在下载时播放它呢?

只要将您的web url更改为本地路径url

请尝试此代码

NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];
如果您使用的是arc 外接程序t.h文件

@property (nonatomic, strong) MPMoviePlayerController *controller;
看看最后一行。祝你好运

NSString *filepath   =   [[NSBundle mainBundle] pathForResource:@"Man of Steel" ofType:@"mp4"];
NSURL    *fileURL    =   [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];

[moviePlayerController.view setFrame:CGRectMake(0,0,500,500)];

[self.view addSubview:moviePlayerController.view];
//moviePlayerController.fullscreen = YES;

//moviePlayerController.scalingMode = MPMovieScalingModeFill;

[moviePlayerController play];

[self setController:moviePlayerController];
}

缓存意味着在本地保存视频?你是说苹果列表中提供的源不起作用吗?好吧,不管怎样-你正在尝试的似乎是一个自制的渐进式下载。在我看来,这在任何情况下都不太明智。我总是建议使用HTTP流媒体。你找到了你尝试做的事情的解决方案吗?你找到了解决方案吗?