Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to download a video file from youtube?
    primarykey
    data
    text
    <p>Bellow i have some code that completes the download process of a youtube video. It works once and then does not work a second time so i put this line of code in <code>[videoData retain];</code> which stops the thread error i was receiving. However once adding <code>[videoData retain];</code> my downloader downloads twice instead of once when downloading a second video it does not do this when downloading the first...</p> <p><strong>Here is my code:</strong></p> <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { videoData = [[NSMutableData alloc] init]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [videoData appendData:data]; } //when downloading done - (void)connectionDidFinishLoading:(NSURLConnection *)connection { filePath = [NSString stringWithFormat:@"%@/Documents/%f.mp4", NSHomeDirectory(),[[NSDate date] timeIntervalSince1970]]; [videoData writeToFile:filePath atomically:YES]; [videoData retain]; [videoData release]; NSLog(@"LOCAL VIDEO LINK %@",filePath); UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Downloading complete" message: @"Download complete. You have successfully downloaded your video from youtube" delegate: self cancelButtonTitle:@"Go Back" otherButtonTitles:@"OK",nil]; [alert show]; [alert release]; } -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { NSLog(@"user pressed Button Indexed 0"); // Any action can be performed here [movieController stop]; [movieController.view removeFromSuperview]; bar.hidden = YES; texturl.text = nil; hidden.hidden = YES; videoData = nil; } else { NSLog(@"user pressed Button Indexed 1"); // Any action can be performed here } } </code></pre> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload