怎么玩m3u8音频文件?

时间:2012-03-29 09:34:51

标签: iphone objective-c m3u8

我有一个网址(http://ms1.clickhere2.com:1935/live/power98/playlist.m3u8)并希望在iPhone中播放,使用m3u8格式,有人会对此有所帮助,我使用了MPMEDIAPLAYER框架和其他东西。

1 个答案:

答案 0 :(得分:4)

试试这样:

NSString *path =[[NSString alloc] initWithString:@"http://stream.alayam.com/alayam/alayam/playlist.m3u8"];



NSURL *audioUrl=[NSURL URLWithString:path];

MPMoviePlayerController *player =  [[MPMoviePlayerController alloc] initWithContentURL:audioUrl];
[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(loadStateDidChange:)                                                 name:MPMoviePlayerLoadStateDidChangeNotification 
                                           object:player];
if ([player respondsToSelector:@selector(loadState)]) 
{
    [player setControlStyle:MPMovieControlModeVolumeOnly];
    [player setFullscreen:YES];
    [player prepareToPlay];
}