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

  • Home
  • SEARCH
  • 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 8664797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:19:44+00:00 2026-06-12T17:19:44+00:00

I have been roaming the internet for a solution I really don’t know what

  • 0

I have been roaming the internet for a solution I really don’t know what am I doing wrong. I have been with this problem a few days now. I save the video at the following path that should be accessible to the application (Right?)

//NSDocumentDirectory doesn't work either.
NSArray *newPath = NSSearchPathForDirectoriesInDomains(NSMoviesDirectory,
                                                       NSUserDomainMask, YES);
NSString *moviesDirectory = [NSString stringWithFormat:@"%@/WebSurg", 
                                                     [newPath objectAtIndex:0]];
// Check if the directory already exists
if (![[NSFileManager defaultManager] fileExistsAtPath:moviesDirectory]) {
    // Directory does not exist so create it
    [[NSFileManager defaultManager] createDirectoryAtPath:moviesDirectory 
                      withIntermediateDirectories:YES attributes:nil error:nil];
}

I show the contents of this directory in a tableView in the application. When a row is tapped it should play the video. But it doesn’t. It shows me the MPMoviePlayerViewController modal view and then hides it after probably what is 1 second. This is the code I use to play it:
I tried two ways of getting the path to no avail.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray *moviesPath = NSSearchPathForDirectoriesInDomains(NSMoviesDirectory, 
                                                              NSUserDomainMask, YES);
    NSString *moviesDirectory = [NSString stringWithFormat:@"%@/WebSurg", 
                                                       [moviesPath objectAtIndex:0]];
    NSString *movie = [self.tableData objectAtIndex:indexPath.row];
    NSString *moviePath = [NSString stringWithFormat:@"%@/%@", 
                                                         moviesDirectory, movie];
    NSURL *movieURL = [NSURL fileURLWithPath:moviePath]; 
    NSLog(@"MOVIEPATH: %@", moviePath);

    NSString *alternatePath = [NSString stringWithFormat:@"%@/%@", 
                                            [[NSBundle mainBundle] resourcePath], movie];
    NSURL *alternateMoviePath = [NSURL fileURLWithPath:moviePath];
    movieViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:alternateMoviePath];
    movieViewController.moviePlayer.movieSourceType= MPMovieSourceTypeFile;
    NSLog(@"Movie Load State: %d", [[movieViewController moviePlayer] loadState]);
    NSLog(@"Alternate movie Path: %@", alternatePath);
    [self presentMoviePlayerViewControllerAnimated:movieViewController];
    [movieViewController.moviePlayer play];
    [self checkAndPlay];
}

- (void) checkAndPlay {
    if ([[self.movieViewController moviePlayer] loadState] == MPMovieLoadStateUnknown) { 
        [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:
                               @selector(checkAndPlay) userInfo:nil repeats:NO];
    } else {
        [self.movieViewController setModalTransitionStyle:
                                   UIModalTransitionStyleCrossDissolve];
        [self presentModalViewController:movieViewController animated:YES];
    }
}

And these are the results of the console:

2012-10-08 10:14:52.392 WebsurgTemplates[3722:17903] MOVIEPATH: /Users/THISISME/Library/Application Support/iPhone Simulator/5.0/Applications/E075DBE3-BFEA-4F6A-9DFA-2CC912E14863/Movies/WebSurg/FirstVideo.mp4
2012-10-08 10:14:52.459 WebsurgTemplates[3722:17903] Movie Load State: 0
2012-10-08 10:14:52.460 WebsurgTemplates[3722:17903] Alternate movie Path: /Users/THISISME/Library/Application Support/iPhone Simulator/5.0/Applications/E075DBE3-BFEA-4F6A-9DFA-2CC912E14863/WebsurgTemplates.app/FirstVideo.mp4

I would greatly appreciate any suggestions and help!!

UPDATE

I made no progress so far. I managed to log some other data to the console, some info that may help more at solving this problem. I tried to make a blank project taking the direct download of the video as link to play the video but it didn’t work. What happens is exactly the same thing. jaydee3 said that maybe it was due because I had probably no access to NSMoviesDirectory. So I changed to NSDocumentDirectory but that didn’t solve the problem. I checked that the file exists and the format in which it is saved so it can be readable by the player. Still it doesn’t work. I don’t know what am I doing wrong. Thanks again for the suggestions/help.

Here the results of the debug. more complete:

if ([[NSFileManager defaultManager] fileExistsAtPath:moviePath]) {
    NSLog(@"FILE EXISTS");
    CFStringRef fileExtension = (__bridge CFStringRef) [moviePath pathExtension];
    CFStringRef fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);

    if (UTTypeConformsTo(fileUTI, kUTTypeImage)) NSLog(@"It's an image");
    else if (UTTypeConformsTo(fileUTI, kUTTypeMovie)) NSLog(@"It's a movie");
    else if (UTTypeConformsTo(fileUTI, kUTTypeText)) NSLog(@"It's text");
}

RESULTS
[6343:17903] MOVIEPATH: /Users/myname/Library/Application Support/iPhone Simulator/5.0/Applications/E075DBE3-BFEA-4F6A-9DFA-2CC912E14863/Documents/FirstVideo.mp4
[6343:17903] FILE EXISTS
[6343:17903] It's a movie
  • 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-06-12T17:19:45+00:00Added an answer on June 12, 2026 at 5:19 pm

    Okay so I managed to solve the problem and find the culprit.

    In a brief note it was because the downloaded movie wasn’t being saved properly (I am currently investigating the possible reasons why). And because of this the player was trying to play a file that existed, was in the correct format and the correct name but that was empty. I found this out by logging all the file sizes after download and transfer and play.

    Now being more descriptive the issue was that I was downloading the movie to the NSCachesDirectory and then saving it to the NSDocumentDirectory. I found this because I started to wonder if it really found the file and if the file was “edible”. It now plays the movie fine as I download it directly to the NSDocumentDirectory. Now I have to solve just in case the connection goes down. As saving in the NSCachesDirectory solved that automatically. I am open to suggestions on that. here is the code that didn’t work to transfer the data from the NSCachesDirectory to NSDocumentDirectory:

    NSArray *paths = NSSearchPathForDirectoriesInDomains
                    // HERE I changed NSCachesDirectory to NSDocumentDirectory fixed it
                                (NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *cachesDirectory = [paths objectAtIndex:0];
    NSString *downloadPath = [cachesDirectory stringByAppendingPathComponent:
                                                      @"DownloadedVideo.mp4"];
    NSArray *newPath = NSSearchPathForDirectoriesInDomains
                                      (NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *moviesDirectory = [NSString stringWithFormat:@"%@", 
                                                    [newPath objectAtIndex:0]];
    self.downloadOperation = [ApplicationDelegate.mainDownloader downloadVideoFrom:
                                        @"http://www.blablabla.web/iphone/download.php"                                    
                                                toFile:downloadPath]; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have been sitting with this problem for a few days and really can't seem
Have been stuck with this issue for a few days now, and really need,
I have been roaming in google with this for couple of hours now. Two
have been working and wearing out my fingers doing google searches with this one:
Have been fighting this for two days and am very frustrated but feel like
There have been multiple questions regarding this topic but I have never really settled
Have been trying to fix this problem I have here. Basically I have a
Have been learning ASP.NET (using C#) over the past few days. I have made
Have been wondering about this for days now: I have a basic wxpython program
Have been working on this question for a couple hours and have come close

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.