标签:http io os 使用 ar for 文件 sp on
可以使用MPMoviePlayerController来播放本地视频文件1.添加 Mediaplayer framework 并且在viewcontroller中#import <MediaPlayer/MediaPlayer.h>
2. 把视频文件拖拽到xcode中
3. 获取文件存放的路径
NSString*thePath=[[NSBundle mainBundle] pathForResource:@"yourVideo" ofType:@"MOV"]; NSURL*theurl=[NSURL fileURLWithPath:thePath];
4. 用该路径初始化moviePlayer
self.moviePlayer=[[MPMoviePlayerController alloc] initWithContentURL:theurl]; [self.moviePlayer.view setFrame:CGRectMake(40, 197, 240, 160)]; [self.moviePlayer prepareToPlay]; [self.moviePlayer setShouldAutoplay:NO]; // And other options you can look through the documentation. [self.view addSubview:self.moviePlayer.view];
5. 添加playback后需要做什么操作的控制
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playBackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; //playBackFinished will be your own method.
http://stackoverflow.com/a/9802543/3458781
标签:http io os 使用 ar for 文件 sp on
原文地址:http://blog.csdn.net/willyang519/article/details/39557913