Storing Videos in the Photo Library(儲存視頻至手機)

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.");

    }


發佈了15 篇原創文章 · 獲贊 0 · 訪問量 13萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章