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 6657297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:45:00+00:00 2026-05-26T01:45:00+00:00

I am recording the video in my application. I am saving that video inside

  • 0

I am recording the video in my application. I am saving that video inside Documents directory. After taking the video if I try to play the video using the following code. The player opens and quits in one seconds. However if I Quit and then open my app fresh the video I took earlier is playing.

+ (void) playMovieAtURL: (NSURL*) theURL :(id)sender{
NSLog(@"playMovieAtURL");
//senderID = (id *)sender;

if ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 3.2) {
    NSLog(@"> 3.2");
    MPMoviePlayerViewController *mp = [[MPMoviePlayerViewController alloc] initWithContentURL:theURL];

    if (mp)
    {
        // save the movie player object
        //self.moviePlayerViewController = mp;
        //[mp release];
        [sender presentMoviePlayerViewControllerAnimated:mp];
        //mp.moviePlayer.movieSourceType = MPMovieSourceTypeFile;
        mp.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
        [mp.moviePlayer play];
    }
    [mp release];

} 
else if ([[[UIDevice currentDevice] systemVersion] doubleValue] < 3.2) {
    NSLog(@"< 3.2");

    MPMoviePlayerController* theMovie = [[MPMoviePlayerController alloc] initWithContentURL: theURL];

    theMovie.scalingMode = MPMovieScalingModeAspectFill;

    // Register for the playback finished notification
    [[NSNotificationCenter defaultCenter]
     addObserver: self
     selector: @selector(myMovieFinishedCallback:)
     name: MPMoviePlayerPlaybackDidFinishNotification
     object: theMovie];

    // Movie playback is asynchronous, so this method returns immediately.
    [theMovie play];
    [theMovie release];


}

}

- (void) moviePlayBackDidFinish:(NSNotification*)notification {  
MPMoviePlayerController *aMoviePlayer = [notification object];  
[[NSNotificationCenter defaultCenter] removeObserver:self  
                                                name:MPMoviePlayerPlaybackDidFinishNotification  
                                              object:aMoviePlayer];  

// If the moviePlayer.view was added to the view, it needs to be removed  
if ([aMoviePlayer respondsToSelector:@selector(setFullscreen:animated:)]) {  
    [aMoviePlayer.view removeFromSuperview];  
}  


}

This is the code I use for storing the video inside documents.

    NSURL *videoURL = [imageInfo objectForKey:UIImagePickerControllerMediaURL];
    NSData *webData = [NSData dataWithContentsOfURL:videoURL];
    self.itsVideoName = fileName;
    [webData writeToFile:[NSString stringWithFormat:@"%@/%@",dataPath,fileName] atomically:TRUE];
  • 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-26T01:45:00+00:00Added an answer on May 26, 2026 at 1:45 am

    I finally figured out the answer after few hours of searching. This is the code I am using now..

      -(IBAction)playMovie:(NSString *) theURL 
    {
    NSURL    *fileURL    =   [NSURL fileURLWithPath:theURL];
    MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
    
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(moviePlaybackComplete:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:moviePlayerController];
    
    [self.view addSubview:moviePlayerController.view];
    //After putting the following line the problem solved.
    moviePlayerController.useApplicationAudioSession = NO;
    moviePlayerController.fullscreen = YES;
    [moviePlayerController play];
    }
    
    - (void)moviePlaybackComplete:(NSNotification *)notification
    {
    MPMoviePlayerController *moviePlayerController = [notification object];
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                      name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:moviePlayerController];
    
    [moviePlayerController.view removeFromSuperview];
    [moviePlayerController release];
    }
    

    the code moviePlayerController.useApplicationAudioSession = NO; is used to solve this problem. I am not sure how this problem solved I guess I am using session for audio I guess that was causing problem to this.

    Also the code which I originally posted was taking lots of memory like if I opened 2 video it cost 104 mb allocation for me. This new code was perfect and it is taking only less memory. Hope this will help for some one..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am recording a video from the iPhone camera by using the AVCam code
I am writing an application that records video on an iPhone using the UIImagePickerController
In my android application i am recording video using Media recorder.I would like to
Following is the code from my audio, video recording project. The audio file is
I created a video recording application with library dialog. The library dialog displays the
My basic requirement is to capture video using UIImagePickerController. The recording of video should
I have just view the iPhone application Touch Cam ( http://itunes.apple.com/us/app/touch-cam-video-recording/id337848815?mt=8 ) which provides
I have a thread in my screen recording application that won't cooperate: package recorder;
Introduction After watching this video from LIDNUG, about .NET code protection http://secureteam.net/lidnug_recording/Untitled.swf (especially from
In my application I recorded a video and then playing. For recording a video

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.