开发者

How do I cache a video for offline playing?

movieURL = [NSURL URLWithString:@"http://122.165.71.249:6060/test/music/killbill.mp3"];
// Setup the player
moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
[[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(moviePlayBackDidFinish:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:nil];
[self presentMoviePlayerViewControllerAnimated:moviePlayer];

I am using this code play online connect开发者_StackOverflow中文版ion ,but i want offline also play in the video url link.


You will have to use an NSURLConnection to download the file yourself, you can then use the original URL for the movie player whilst downloading the video at the same time. When I did this I tried to get the video player to use the local file before I has finished, by delaying start of playback after a certain number of bytes have been received, but I found it would only work on the simulator but not on the actually iPhone/iPodTouch. If you do search for (MPMoviePlayerViewController "Nathan Day" Cache) you will see some example code I post on Apples Cocoa mailing trying to solve this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜