星期四, 1月 05, 2017

[Objective-C] AVPlayer 操作筆記

測試一下用Objective-C播放影片的sample

Sample檔放到專案

前面二個項目要打勾

取得應用程式目錄的檔案


//NSBundle resourcePath


    NSString *filePath=[[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"SampleVideo_360x240_30mb.mp4"];


//NSBundle URLForResource


 NSURL *sourceMovieURL = [[NSBundle mainBundle]URLForResource:@"SampleVideo_360x240_30mb" withExtension:@"mp4"];

   建立AVPlayer




    AVPlayer *player =
        [[AVPlayer alloc] initWithURL:sourceMovieURL];
//        [AVPlayer playerWithURL:sourceMovieURL];
    
    AVPlayerViewController *playerController = [AVPlayerViewController new];
    
    playerController.player = player;
    [self addChildViewController:playerController];
    [self.view addSubview:playerController.view];
    playerController.view.frame = self.view.frame;
    
    [player play];    

https://support.apple.com/zh-tw/HT201549

http://pinkstone.co.uk/how-to-play-videos-in-ios-9/

http://iphoneincubator.com/blog/data-management/how-to-read-a-file-from-your-application-bundle

完整的iOS實作影片/音樂的解法
http://www.cnblogs.com/XYQ-208910/p/5159726.html

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails