Iphone – Play video from cache in iphone programmatically

cachingiphonempmovieplayermpmovieplayercontroller

I am developing an iPhone application in which I will store stream video from URL directly to cache in local, now I need to play video in movie-player while it was in downloading in cache. I followed this http://lists.apple.com/archives/cocoa-dev/2011/Jun/msg00844.html, but I couldn't do exact. I am able to download video in cache but I couldn't play video from cache. So how can I play while its downloading?

Best Answer

Just change your web url to local path url...

Try this code...

NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:@"Movie" ofType:@"m4v"];
NSURL *movieURL = [[NSURL fileURLWithPath:moviePath] retain];
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMovie.scalingMode = MPMovieScalingModeAspectFill;
[theMovie play];