Play video from cache in iphone programmatically
Asked Answered
M

2

15

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?

Mcardle answered 13/9, 2011 at 13:21 Comment(3)
cache meaning saving the video locally?Breger
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.Poon
Did you find any solution for this thing that you try to do?Morrill
B
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];
Bifarious answered 22/9, 2011 at 6:36 Comment(0)
R
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];
}
Ridicule answered 7/5, 2013 at 15:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.