以编程方式从iphone中缓存播放视频 [英] Play video from cache in iphone programmatically

查看:300
本文介绍了以编程方式从iphone中缓存播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个iPhone应用程序,我将URL中的流视频直接存储到本地缓存中,现在我需要在缓存中下载时在电影播放器​​中播放视频。我按照这个 http://lists.apple.com/archives /cocoa-dev/2011/Jun/msg00844.html ,但我做不到。我可以在缓存中下载视频但我无法从缓存中播放视频。那么下载时怎么玩?

I am developing an iPhone application in which I will store stream video from URL directly to cache in local, now I need to play video in movie-player while it was in downloading in cache. I followed this http://lists.apple.com/archives/cocoa-dev/2011/Jun/msg00844.html, but I couldn't do exact. I am able to download video in cache but I couldn't play video from cache. So how can I play while its downloading?

推荐答案

如果你使用arc
添加t .h文件

if you are using arc add in t .h file

@property (nonatomic, strong) MPMoviePlayerController *controller;

并查看最后一行。祝你好运

and take a look at the last line. good luck

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];
}

这篇关于以编程方式从iphone中缓存播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆