How to play m3u8 audio file?
-
27-05-2021 - |
Pregunta
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.
Solución
Try like this:
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];
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow