私は一日中解決しようとしてきた問題を抱えていて、壁に頭をぶつけるのにうんざりしています. 誰でもこれを行う方法を知っていますか?
ナンバーワンワークスグレート
よく働く
- (void) viewDidLoad { [super viewDidLoad]; NSURL *url = [NSURL URLWithString:@"http://techslides.com/demos/sample-videos/small.mp4"]; AVPlayer *avPlayer = [[AVPlayer alloc] initWithURL:url]; self.player = avPlayer; [self.player play]; }
動作しません
- (void) viewDidLoad { [super viewDidLoad]; CKAsset *asset = record[@"VideoFile"]; AVPlayer *avPlayer = [[AVPlayer alloc] initWithURL:asset.fileURL]; self.player = avPlayer; [self.player play]; }
動作しません
- (void) viewDidLoad { [super viewDidLoad]; CKAsset *asset = record[@"VideoFile"]; NSString *fileName = record[@"videoFileKey"]; NSData *data = [NSData dataWithContentsOfURL:asset.fileURL]; NSString *cachesDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString *path = [cachesDirectoryPath stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.mp4", fileName]]; [data writeToFile:path atomically:YES]; if ([[NSFileManager defaultManager] fileExistsAtPath:path]) { NSURL *url = [NSURL URLWithString:path]; AVPlayer *avPlayer = [[AVPlayer alloc] initWithURL:url]; self.player = avPlayer; [self.player play]; } }