我的应用在文档文件夹中有视频内容 /播放列表/ - 它是播放列表文件夹我使用m3u格式。 / videoContent / - 这是视频文件夹。
FIRST。 当我使用代码加载播放列表和来自服务器的内容
运行播放器时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
然后我会在第一次尝试时看到一些日志消息。
THIRD 从文档文件夹播放播放列表,播放列表包含完整路径。
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 :(得分:-3)
如果出现同样的问题,请在设置SourceType之后尝试设置ContentURL,如下所示
moviePlayerController_ = [[MPMoviePlayerViewController alloc] init];
moviePlayerController_.movieSourceType = MPMovieSourceTypeStreaming;
[moviePlayerController_.moviePlayer setContentURL:url];
来源:devforums.apple.com/message/467199
希望有所帮助
答案 1 :(得分:-3)
我认为这是由静态播放器引起的。尝试使用电影播放器的属性
使用:
@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];