2011-06-29 35 views
4
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]; 

我正在使用此代碼播放在線連接,但我希望脫機播放視頻網址鏈接。如何將視頻緩存爲離線播放?

回答

0

您將不得不使用NSURLConnection自行下載文件,然後可以在下載視頻的同時使用電影播放器​​的原始URL。當我這樣做時,我試圖讓視頻播放器在完成之前使用本地文件,在接收到一定數量的字節後延遲播放開始,但是我發現它只能在模擬器上工作,而不能在實際上是iPhone/iPodTouch。如果您搜索(MPMoviePlayerViewController「Nathan Day」Cache),您會看到一些示例代碼,我在Apples Cocoa郵件上試圖解決這個問題。

+1

我解決了這個問題,我將mp3文件保存到文檔目錄路徑中,謝謝你的回覆 –