Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing .m3u8 file on iOS

I have .m3u8 link which I need to play on iOS which supports the HLS Protocol.

When I assign URL directly to the MPMoviePlayerController and play, video is not visible but I can hear the audio.

NSURL *movieURL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[self.view addSubview:self.moviePlayer.view];

if (mp)
{
    // save the movie player object
    self.moviePlayer = mp;
    [self.moviePlayer setFullscreen:YES];

    // Play the movie!
    [self.moviePlayer play];
}

What additional stuff do I need to do on iOS side?

like image 294
Vip's Avatar asked Mar 03 '14 05:03

Vip's


People also ask

How do I download M3U8 files on a Mac?

Open the Mac App Store to buy and download apps. This is a stream player that can read every stream in the m3u8 format. Just add the url you want and enjoy. Worked where nothing else would.

Can I play M3U8 on my Android phone?

Unfortunately, only Android users can download the m3u8 loader. This is another simple application to play videos and music. It is truly universal – it can work with hls, m3u, mp4, as well as other formats. The app works just like a player.

How to play M3U file without jailbreaking the device?

On Android there are many apps like Total Commander that can play m3u files with radio streams. Here is an example content of such a m3u file: Is there any way to play this file without jailbreaking the device? Show activity on this post. GSE SMART IPTV app is recommended to playback M3U streams on iOS devices.


1 Answers

Import:

#import <MediaPlayer/MediaPlayer.h>

Then do:

NSURL *movieURL = [NSURL URLWithString:@"http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

if (mp) {
    mp.view.frame = self.view.bounds;
    [self.view addSubview:mp.view];

    // save the movie player object
    [mp setFullscreen:YES];

    // Play the movie!
    [mp play];

    self.moviePlayer = mp;
}
like image 91
iCoder Avatar answered Sep 23 '22 19:09

iCoder