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?
Asked
Active
Viewed 5,837 times
15
-
cache meaning saving the video locally? – ThE uSeFuL Sep 14 '11 at 08:59
-
Are you saying that the provided source from the apple list is not working? Well, anyways - what you are trying seems to be a self-made progressive download. To me, that seems not clever to do in pretty much any case. I would always advise to use HTTP-streaming. – Till Oct 02 '11 at 18:38
-
Did you find any solution for this thing that you try to do? – YosiFZ Mar 29 '12 at 16:36
2 Answers
1
if you are using arc add in t .h file
@property (nonatomic, strong) MPMoviePlayerController *controller;
and take a look at the last line. good luck
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"Man of Steel" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[moviePlayerController.view setFrame:CGRectMake(0,0,500,500)];
[self.view addSubview:moviePlayerController.view];
//moviePlayerController.fullscreen = YES;
//moviePlayerController.scalingMode = MPMovieScalingModeFill;
[moviePlayerController play];
[self setController:moviePlayerController];
}

Juliano Alves
- 2,006
- 4
- 35
- 37

Udi Levy
- 11
- 2
1
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];

Sonu
- 937
- 1
- 10
- 39