2

i have a problem in my app

i'm downloading a zip in my app and adding it on NSDocumentDirectory, this zip have some images and a movie.

I can access and show all images, but i can't play the video

if my video is on bundle directory i use this code and i can play the video

the code: NSString *path = [[NSBundle mainBundle] pathForResource: @"videoName" ofType: @"mov"]; MPMoviePlayerViewController *viewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]]; [self presentMoviePlayerViewControllerAnimated:viewController];

it's work if my video is on bundle directory, but i tried many ways to play the video from NSDocumentDirectory.

Anyone can help me?

Thanks.

Nathan Hegedus
  • 344
  • 6
  • 15
  • are you using the right path for your video resource? – LuisEspinoza Mar 15 '12 at 18:52
  • Post the code that you're using for get the path in documents, maybe we can get an answer. – LuisEspinoza Mar 15 '12 at 19:02
  • my code: NSString *fileURLWithPath:movie = [_documentsDir stringByAppendingPathComponent:@"1/1.mov"]; NSURL *movieURL = [NSURL fileURLWithPath:movie]; MPMoviePlayerViewController *viewController = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL]; [self presentMoviePlayerViewControllerAnimated:viewController]; [viewController release]; but i dont know how, now it's worked!!! \o/ – Nathan Hegedus Mar 15 '12 at 19:50
  • but i have another problem, i need play videos from youtube and it doesnt work, how can i adjust this code to play a youtube video? – Nathan Hegedus Mar 15 '12 at 19:51

1 Answers1

2

For Youtube Videos you can send the url to the shared application and this will open the video in the YouTube.app for iOS

NSString *stringURL = @"http://www.youtube.com/watch?v=K8ecN36Ffpc";
NSURL *url = [NSURL URLWithString:stringURL];
[[UIApplication sharedApplication] openURL:url];

this works also for this other type of youtube urls

NSString *stringURL = @"http://www.youtube.com/v/K8ecN36Ffpc";
javiergov
  • 953
  • 6
  • 17