-湛蓝_大神你好!
我这边在使用 PKPlayerView 不能播放短视频;具体代码如下:
录制视频:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *fileName = [NSProcessInfo processInfo].globallyUniqueString;
NSString *path = [paths[0] stringByAppendingPathComponent:[fileName stringByAppendingPathExtension:@"mp4"]];
//跳转默认录制视频ViewController
PKRecordShortVideoViewController *viewController = [[PKRecordShortVideoViewController alloc] initWithOutputFilePath:path outputSize:CGSizeMake(320, 240) themeColor:[UIColor colorWithRed:0/255.0 green:153/255.0 blue:255/255.0 alpha:1]];
//通过代理回调
viewController.delegate = self;
[self presentViewController:viewController animated:YES completion:nil];
播放视频:
-
(void)didFinishRecordingToOutputFilePath:(NSString *)outputFilePath{
_outputFilePath = outputFilePath;
_playerView = [[PKPlayerView alloc] initWithFrame:CGRectMake(30, 30, kScreenWidth - 60, 200)
videoPath:_outputFilePath
previewImage:[UIImage pk_previewImageWithVideoURL:[NSURL fileURLWithPath:_outputFilePath]]];
[self.view addSubview:_playerView];
UITapGestureRecognizer *tapp = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playViewAction)];
[_playerView addGestureRecognizer:tapp];
}
-
(void)playViewAction{
//跳转全屏播放小视频界面
[_playerView play];
}
谢谢!
-湛蓝_大神你好!
我这边在使用 PKPlayerView 不能播放短视频;具体代码如下:
录制视频:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *fileName = [NSProcessInfo processInfo].globallyUniqueString;
NSString *path = [paths[0] stringByAppendingPathComponent:[fileName stringByAppendingPathExtension:@"mp4"]];
//跳转默认录制视频ViewController
PKRecordShortVideoViewController *viewController = [[PKRecordShortVideoViewController alloc] initWithOutputFilePath:path outputSize:CGSizeMake(320, 240) themeColor:[UIColor colorWithRed:0/255.0 green:153/255.0 blue:255/255.0 alpha:1]];
//通过代理回调
viewController.delegate = self;
[self presentViewController:viewController animated:YES completion:nil];
播放视频:
(void)didFinishRecordingToOutputFilePath:(NSString *)outputFilePath{
_outputFilePath = outputFilePath;
_playerView = [[PKPlayerView alloc] initWithFrame:CGRectMake(30, 30, kScreenWidth - 60, 200)
videoPath:_outputFilePath
previewImage:[UIImage pk_previewImageWithVideoURL:[NSURL fileURLWithPath:_outputFilePath]]];
[self.view addSubview:_playerView];
UITapGestureRecognizer *tapp = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(playViewAction)];
[_playerView addGestureRecognizer:tapp];
}
(void)playViewAction{
//跳转全屏播放小视频界面
[_playerView play];
}
谢谢!