我的应用在文档文件夹 /playlists/ 中有视频内容 - 它是我使用 m3u 格式的播放列表文件夹。/videoContent/ - 这是视频文件夹。
第一的。当我使用代码运行播放器以从服务器加载播放列表和内容时
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
日志
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-all 播放来自外部视频流服务器的播放列表也很好。
player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/gear3/prog_index.m3u8"]];
发生了什么?我不知道。