1. Video export:
Uialertcontroller *av = [Uialertcontroller alertcontrollerwithtitle:@"Hint"message:@"Are you sure you want to export the video to an album?"Preferredstyle:uialertcontrollerstyleactionsheet]; [AV addaction:[uialertaction actionwithtitle:@"OK"Style:uialertactionstyledefault handler:^ (uialertaction * _nonnull action) {//Save video to album (Async thread) //videosuccessi Record the number of successful uploadsVideosuccessi =0;//allvideos Remove the video name from all the videos in the sandboxAllvideos = [Databasetool Videofromdb]; [Svprogresshud showwithstatus:@"Exporting, please be patient ..."]; for(NSString*videoname in Allvideos) {//urlstr The full path of the video inside the sandbox NSString*URLSTR = [[Nssearchpathfordirectoriesindomains (NSDocumentDirectory, Nsuserdomainmask,YES) Objectatindex:0] Stringbyappendingpathcomponent:videoname];Dispatch_async(Dispatch_get_global_queue (Dispatch_queue_priority_default,0), ^{if(Uivideoatpathiscompatiblewithsavedphotosalbum (URLSTR)) {//Save album Core codeUisavevideoatpathtosavedphotosalbum (URLSTR, Self,@selector(Video:didFinishSavingWithError:contextInfo:),Nil); } }); } }]];
#pragma mark videos saved callbacks- (void) Video: (NSString*) Videopath Didfinishsavingwitherror: (Nserror*) Error ContextInfo: (void*) contextinf{if(Error) {[Svprogresshud showerrorwithstatus:@"Export failed!"]; [Svprogresshud dismiss];NSLog(@"error occurred during video save, error message:%@", error. Localizeddescription); }Else{videosuccessi++;if(Videosuccessi = = Allvideos. Count) {[Svprogresshud showsuccesswithstatus:@"The video export is successful, please view it in the album!"]; Dispatch_after (Dispatch_time (Dispatch_time_now, (int64_t) (0.8* nsec_per_sec)), Dispatch_get_main_queue (), ^{[Svprogresshud dismiss]; });//Uialertcontroller *av = [Uialertcontroller alertcontrollerwithtitle:nil message:@ "The video export is successful, please view it in the album!" Prefe Rredstyle:uialertcontrollerstylealert];//[self presentviewcontroller:av animated:yes completion:nil];}NSLog(@"Video saved successfully."); }}
ios-in-sandbox video export to albums