views:

121

answers:

1

Hi all,

Im trying to download a video/audio on iphone and store in iPhone system bundle, and play the video/audio file from bundle.

I have successfully downloaded the video/audio file using NSURLConnection. and i have store it as "sample.mov"

but i wasn't able to play the video from bundle. is it because the file was not registered in bundle?!

Here is the code:

write to file when finish downloading

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"sample.mov"];

    [VideoData writeToFile:path atomically:YES];
}

then i play the video from bundle

MoviePlayerAppDelegate *appDelegate = (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];

    // play the movie
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:@"a" ofType:@"mov"];
    NSURL *movURL = [NSURL fileURLWithPath:moviePath];

    [appDelegate initAndPlayMovie:movURL];


-(void)initAndPlayMovie:(NSURL *)movieURL
{
    MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
    if (mp)
    {
     // save the movie player object
     self.moviePlayer = mp;
     [mp release];

     // Apply the user specified settings to the movie player object
     [self setMoviePlayerUserSettings];

     // Play the movie!
     [self.moviePlayer play];
    }
}
A: 

To my knowledge you cannot successfully save files to resource bundle folder.

SKG