如何播放 m3u8 音频文件? [英] How to play m3u8 audio file?

查看:310
本文介绍了如何播放 m3u8 音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址(http://ms1.clickhere2.com:1935/live/power98/playlist.m3u8) 并想在 iPhone 上玩 m3u8 格式,有人可以帮忙吗,我使用过 MPMEDIAPLAYER 框架和其他东西.

I have a URL (http://ms1.clickhere2.com:1935/live/power98/playlist.m3u8) and wanted to play in iPhone, with m3u8 format, would somebody help on this, I have used MPMEDIAPLAYER framework and other things.

推荐答案

试试这个:

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];
}   

这篇关于如何播放 m3u8 音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆