标签:style blog http color 使用 strong
1>音频播放
2>视频播放
两个视频播放类的区别:
MPMoviePlayerController继承自NSObject;
// 加载视频资源 NSString *urlString = [[NSBundle mainBundle] pathForResource:@"sample_iTunes" ofType:@"mov"]; NSURL *url = [NSURL fileURLWithPath:urlString]; // 创建播放器 _player = [[MPMoviePlayerController alloc] initWithContentURL:url]; // 设置尺寸 _player.view.frame = self.view.bounds; _player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; // 添加到控制器的view上 [self.view addSubview:_player.view]; // 播放 [_player play];
// 监听播放状态的改变 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(videoStateChange)
name:MPMoviePlayerPlaybackStateDidChangeNotification object:_player]; // 监听播放器结束全屏 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(exitFullscreen)
name:MPMoviePlayerDidExitFullscreenNotification object:_player];
其它属性、方法:
是否要自动播放 @property(nonatomic) BOOL shouldAutoplay; 全屏显示 @property(nonatomic, getter=isFullscreen) BOOL fullscreen; - (void)setFullscreen:(BOOL)fullscreen animated:(BOOL)animated; 截取视频中的图片 - (void)requestThumbnailImagesAtTimes:(NSArray *)playbackTimes timeOption:(MPMovieTimeOption)option;
完整代码:视频播放
附:
1>添加图片到系统相册中
UIImageWriteToSavedPhotosAlbum([UIImage imageNamed:@"Default.png"], self, @selector(image:didFinishSavingWithError:contextInfo:), NULL);
标签:style blog http color 使用 strong
原文地址:http://www.cnblogs.com/yaoxc/p/3857437.html