Storing Videos in the Photo Library(储存视频至手机)

来源:互联网 发布:sem优化是什么意思 编辑:程序博客网 时间:2024/05/17 22:22

1。导入:#import <AssetsLibrary/AssetsLibrary.h>

   方法:writeVideoAtPathToSavedPhotosAlbum


e.g.

   ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init]; 

    //将应用程序中可获取到的视频资源MyVideo.MOV存入手机

    NSURL *videoURL = [[NSBundle mainBundle]  URLForResource:@"MyVideo"  withExtension:@"MOV"];

    if (videoURL != nil){

        [assetsLibrary writeVideoAtPathToSavedPhotosAlbum:videoURL

            completionBlock:^(NSURL *assetURL, NSError *error) {             

             if (error == nil){

                 NSLog(@"succeed in saving videos,no errors happened");

             } else {

                 NSLog(@"Error happened while saving the video.");

                 NSLog(@"The error is = %@", error);

             }             

         }];

    } else {

        NSLog(@"Could not find the video in the app bundle.");

    }


0 0