Created
November 25, 2016 16:04
-
-
Save rbreve/bd1c732ed99f7e3f16cc7bced5d6ea28 to your computer and use it in GitHub Desktop.
download video
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(void) downloadVideo:(NSString *) urlToDownload | |
| { | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| NSLog(@"Downloading Started"); | |
| NSURL *url = [NSURL URLWithString:urlToDownload]; | |
| NSData *urlData = [NSData dataWithContentsOfURL:url]; | |
| if ( urlData ) | |
| { | |
| NSString *outputURL = NSTemporaryDirectory(); | |
| outputURL = [outputURL stringByAppendingPathComponent:@"downloaded.mp4"]; | |
| //saving is done on main thread | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| [urlData writeToFile:outputURL atomically:YES]; | |
| NSLog(@"downloaded! %@", outputURL); | |
| [self.loadingImageIndicator setHidden:YES]; | |
| self.videoView = [[VideoPlayerView alloc] init]; | |
| [self loadVideoToView:[NSURL fileURLWithPath:outputURL]]; | |
| }); | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment