2014-01-10 90 views
1

我的應用程序具有視頻內容的文檔文件夾 /播放/ - 它的播放列表文件夾,我使用M3U格式。 /videoContent/- 這是視頻文件夾中。的MPMoviePlayerController無法從文件夾播放的播放列表和視頻

第一位。 當我從服務器負載播放列表和內容代碼運行播放器

player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://mbp.local/rat/playlists/Playlist.a60df6084e7d38b12f84afc602bb39ef.m3u"]]; 

M3U

#EXTM3U 

#EXTINF:3000,abc 
http://mbp.local/rat/videoContent/1.82aa02198c0255eddc1e538c184c176b.mov 

#EXTINF:3111,cab 
http://mbp.local/rat/videoContent/9.4e574f9485a9031c536425b7f79ef545.mp4 

那不是與信息工程日誌:

2014-01-11 04:06:04.573 RAT[736:70b] Internal Log: Video playing 
2014-01-11 04:06:04.606 RAT[736:70b] Internal Log: Video paused 
2014-01-11 04:06:04.615 RAT[736:70b] Internal Log: Video playing 
2014-01-11 04:06:04.680 RAT[736:70b] _itemFailedToPlayToEnd: { 
    kind = 1; 
    new = 2; 
    old = 0; 
} 
2014-01-11 04:06:04.683 RAT[736:70b] Internal Log: Video stopped 
2014-01-11 04:06:04.688 RAT[736:70b] Internal Log: Video stopped 

第二

當我嘗試從文檔文件夾播放播放列表。

player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[NSString stringWithFormat: @"%@/playlists/Playlist.a60df6084e7d38b12f84afc602bb39ef.m3u",documentsFolderPath]]]; 

m3u具有規範中描述的相對路徑。

#EXTM3U 

#EXTINF:3000,abc 
../videoContent/1.82aa02198c0255eddc1e538c184c176b.mov 

#EXTINF:3111,cab 
../videoContent/9.4e574f9485a9031c536425b7f79ef545.mp4 

然後我在第一次嘗試中看到一些日誌消息。

第三,從文件夾 播放播放列表以及播放列表中包含完整路徑。

player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[NSString stringWithFormat: @"%@/playlists/Playlist.a60df6084e7d38b12f84afc602bb39ef.m3u",documentsFolderPath]]]; 

M3U

#EXTM3U 

#EXTINF:3000,abc 
/Users/royalblue/Library/Application Support/iPhone Simulator/7.0.3/Applications/96C671E3-EE7F-484E-A548-846E4D917CDD/Documents/videoContent/1.82aa02198c0255eddc1e538c184c176b.mov 

#EXTINF:3111,cab 
/Users/royalblue/Library/Application Support/iPhone Simulator/7.0.3/Applications/96C671E3-EE7F-484E-A548-846E4D917CDD/Documents/videoContent/9.4e574f9485a9031c536425b7f79ef545.mp4 

LOG

2014-01-11 04:09:11.220 RAT[788:70b] Internal Log: Video playing 
2014-01-11 04:09:11.241 RAT[788:70b] Internal Log: Video paused 
2014-01-11 04:09:11.247 RAT[788:70b] Internal Log: Video playing 
2014-01-11 04:09:11.254 RAT[788:70b] Internal Log: Video stopped 
2014-01-11 04:09:11.308 RAT[788:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'An AVPlayerItem cannot be associated with more than one instance of AVPlayer' 
*** First throw call stack: 
(
    0 CoreFoundation      0x01ed05e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x018768b6 objc_exception_throw + 44 
    2 AVFoundation      0x00161101 -[AVPlayerItem _attachToFigPlayer] + 0 
    3 AVFoundation      0x00152ebb -[AVPlayer _attachItem:andPerformOperation:withObject:] + 286 
    4 AVFoundation      0x00151eb3 -[AVPlayer _insertItem:afterItem:] + 55 
    5 AVFoundation      0x001726fe -[AVQueuePlayer insertItem:afterItem:] + 148 
    6 MediaPlayer       0x01b88c53 -[MPQueuePlayer insertItem:afterItem:] + 68 
    7 MediaPlayer       0x01b6367e __89-[MPAVQueuePlayerFeeder _updatePlayerQueueWithRemovedItems:addedItems:removeCurrentItem:]_block_invoke382 + 890 
    8 libdispatch.dylib     0x0216a7f8 _dispatch_call_block_and_release + 15 
    9 libdispatch.dylib     0x0217f4b0 _dispatch_client_callout + 14 
    10 libdispatch.dylib     0x0216d75e _dispatch_main_queue_callback_4CF + 340 
    11 CoreFoundation      0x01f35a5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14 
    12 CoreFoundation      0x01e766bb __CFRunLoopRun + 1963 
    13 CoreFoundation      0x01e75ac3 CFRunLoopRunSpecific + 467 
    14 CoreFoundation      0x01e758db CFRunLoopRunInMode + 123 
    15 GraphicsServices     0x027f89e2 GSEventRunModal + 192 
    16 GraphicsServices     0x027f8809 GSEventRun + 104 
    17 UIKit        0x005e4d3b UIApplicationMain + 1225 
    18 RAT         0x0000cfad main + 141 
    19 libdyld.dylib      0x0241170d start + 1 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

但是,如果我直接播放視頻文件從服務器或沒有播放列表 - 無一不精。

player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:[NSString stringWithFormat: @"%@/videoContent/1.82aa02198c0255eddc1e538c184c176b.mov",documentsFolderPath]]]; 

如果我從外部視頻流媒體服務器與m3u播放播放列表 - 都很好。

player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear3/prog_index.m3u8"]]; 

這是怎麼回事?我不知道。

+0

你找到一個解決辦法? – mattsson

+0

號我所理解的MPMoviePlayerController無法與本地文件的播放M3U播放列表。我只是創建自己的播放列表格式,播放列表解析器功能和播放列表功能。這並不簡單,但我沒有看到另一種方式來實現它。 –

回答

-3

曾有同樣的問題,請嘗試將像下面的SourceType中之後設置的contentURL,

moviePlayerController_ = [[MPMoviePlayerViewController alloc] init]; 
moviePlayerController_.movieSourceType = MPMovieSourceTypeStreaming; 
[moviePlayerController_.moviePlayer setContentURL:url]; 

來源:devforums.apple.com/message/467199

希望它可以幫助

+0

這沒有幫助。謝謝。 –

-3

我覺得這是由於靜態球員。嘗試使用movieplayer

使用的屬性:

@property (nonatomic,retain) MPMoviePlayerController *player; 
In implementation: 

@synthesize player = _player; 
In init: 

MPMoviePlayerController *plyr = [MPMoviePlayerController alloc] init]; 
self.player = plyr; 
[plyr relaease]; 
In your code 

[controller setContentURL:movieURL]; 
+0

它應該工作.....祝你好運 –