2014-01-10 56 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

它应该工作.....祝你好运 –