Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6948387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:48:58+00:00 2026-05-27T13:48:58+00:00

In my iPhone app, I am taking video using ImagePickerview and storing it to

  • 0

In my iPhone app, I am taking video using ImagePickerview and storing it to document directory

For iOS4 (device iPod) I can play video stored in document directory but for iOS 5 (device iPad) the same code is not working for playing video.

so for iOS 5 is there any different way for storing and playing video from document directory

(I also tried with library directory)

  -(IBAction)saveVideo:(id)sender
    {  
    imagepicker = [[UIImagePickerController alloc] init];
      imagepicker.delegate=self;
     if([UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        [imagepicker setSourceType:UIImagePickerControllerSourceTypeCamera];
        [imagepicker setMediaTypes:[UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera]];

         [imagepicker setCameraDevice:UIImagePickerControllerCameraCaptureModeVideo];

        [self presentModalViewController:imagepicker animated:YES];

    } 


 }



    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
  {


     NSMutableString *tempPath = [[[info valueForKey:@"UIImagePickerControllerMediaURL"] absoluteString] mutableCopy];
    NSString *newPath1 = [NSString stringWithFormat:@"myVideo.mov"];
   [tempPath replaceOccurrencesOfString:@"file://localhost/private/" withString:@"/" options:NSCaseInsensitiveSearch range:NSMakeRange(0, [tempPath length])];
   NSFileManager *manager = [NSFileManager defaultManager];
   NSError *error = nil;
  [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject], newPath1];
   NSString *newPath = [NSString stringWithFormat:@"%@/%@", [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject], newPath1];


   BOOL success = [manager copyItemAtPath:tempPath toPath:newPath error:&error];

     if(error){         
    NSLog(@"New Path: %@", newPath);
    NSLog(@"Error: %@", error);
  }

   if(success)
   {
    NSLog(@"Succeed");     
   }
     [self dismissModalViewControllerAnimated:YES];
   }


    - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
   {
   [picker dismissModalViewControllerAnimated:YES];
   }


    -(IBAction)playVideo:(id)sender
    {
    NSArray *path=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [path objectAtIndex:0];
    NSString *myDBnew = [documentsDirectory stringByAppendingPathComponent:@"myVideo.mov"];

     NSURL *url = [[NSURL alloc] initWithString:myDBnew];
    NSLog(@"URL== %@",url);
    moviePlayer =  [[MPMoviePlayerController alloc]
                    initWithContentURL:url];

    //        [[NSNotificationCenter defaultCenter] addObserver:self
    //                                                 selector:@selector(moviePlayBackDidFinish:)
    //                                                     name:MPMoviePlayerPlaybackDidFinishNotification
    //                                                   object:moviePlayer];

    moviePlayer.controlStyle = MPMovieControlStyleDefault;
    moviePlayer.shouldAutoplay = YES;
    [self.view addSubview:moviePlayer.view];
    [moviePlayer setFullscreen:YES animated:YES];
    }

What could be wrong?

Here is the code.

If I add the video file into my project and use below code it is playing Video The only thing is it is not playing video from document directory

    NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"myVideo" ofType:@"mov"]];
    moviePlayer =  [[MPMoviePlayerController alloc]
                    initWithContentURL:url];

Even in iTunes via flittering I can see the file:”myVideo.mov”, after running the app in device means This codes recording and storing video but not able to read or play.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T13:48:59+00:00Added an answer on May 27, 2026 at 1:48 pm

    Here in my code the problem was the way i am creating url

       NSURL *url = [[NSURL alloc] initWithString:myDBnew];
    

    which doesn’t work for ios5 so i replaced in code by

      NSURL *url = [[NSURL alloc] initFileURLWithPath:<#(NSString *)#> isDirectory:<#(BOOL)#>];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my iphone app crashes unexpectedly and looking at the crash log I can't tell
My iPhone app formats an NSDecimalNumber as a currency using setCurrencyCode, however another screen
I am new to iphone app development, while taking picture from camera I am
How can I change the time the default screen appears in an iPhone app?
I am developing an iPhone application which plays the video using MPMoviePlayerController . When
I wanted to write an Android and/or an iPhone app that entails taking a
Possible Duplicate: What tool(s) can I use to produce iPhone App Screencasts? I've heard
The iPhone app that I am working on requires GET calls to a 3rd
My iPhone app started logging this error: lo->hi recycling invariant violated! followed by: Program
My iPhone app generally uses under 5MB of living memory and even in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.