MPMoviePlayerController iOS stream m3u8 file not working - ios

im trying to play a m3u8 live streaming file by using this code:
NSURL *movieURL = [NSURL URLWithString:#"http://www.streaming507.com:1935/TVBlast/TVBlast/playlist.m3u8"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
[self.view addSubview:mp.view];
[mp setFullscreen:YES animated:YES];
mp.movieSourceType = MPMovieSourceTypeStreaming;
[mp play];
}
when i copy/paste streaming507.com:1935/TVBlast/TVBlast/playlist.m3u8 in my device in safari browser it plays perfect and it works good how i can fix this?
I dont know what im doing wrong
thank you

i fix the problem by copy/paste this in my info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<!--Include to allow all connections (DANGER)-->
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

Related

Video Not playing in iOS 10

In the following code:
// NSURL *videoURL1 = [NSURL URLWithString:[NSString stringWithFormat:#"http://www.ebookfrenzy.com/ios_book/movie/movie.mov"]];
NSURL *videoURL2 = [NSURL URLWithString:[NSString stringWithFormat:#"https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"]];
AVPlayer *playerV = [AVPlayer playerWithURL:videoURL];
AVPlayerViewController *playerViewController = [AVPlayerViewController new];
playerViewController.player = playerV;
[self presentViewController:playerViewController animated:YES completion:^{
[playerV play];
}];
VideoURL1 is working but videoURL2 is not working and the screen is like this:
I added keys and values in info.plist:
Reason behind not working you second url is that you are whitelisting only "http://www.ebookfrenzy.com" which does not support support secure connection. You should also whitelist "clips.vorwaerts-gmbh.de" in the same manner you have whitelisted "http://www.ebookfrenzy.com" . If you are going to access video from many site dynamically which does not support secure connection(https) then and the below line in your plist.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
For more detail have a look on following thread-
How do I load an HTTP URL with App Transport Security enabled in iOS 9?

How to achieve Live Streaming of videos in iOS (iPhone/iPad) using Kaltura?

i m able to play Live Streaming Video in iOS using following code :
NSURL *mediaURL = [NSURL URLWithString:#"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:mediaURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
mp.view.frame = self.view.bounds;
[mp setControlStyle:MPMovieControlStyleFullscreen];
[mp setMovieSourceType:MPMovieSourceTypeStreaming];
//[mp setFullscreen:YES];
[self.view addSubview:[mp view]];
[mp prepareToPlay];
[mp play];
what i m passing is .m3u8 file format url to the MPMoviePlayerController, and i m able to play Live Streaming. but how can i achieve it using Kaltura's Live Streaming ?
according to http://corp.kaltura.com/company/news/press-release/kaltura-%E2%80%98cracks-code%E2%80%99-reliable-hls-video-streaming-android-devices there is Android SDK for live streaming of videos using Kaltura, is there any iOS Kaltura SDK for Live Streaming ? or Do i have to use iOS built in MPMoviePlayerController for Live Streaming , if yes then what is the way ?
Please Help.
In order to play Kaltura live streaming you just need to grab the manifest url with the following params:
/format/applehttp/protocol/http/a.m3u8
more details here:
http://knowledge.kaltura.com/faq/how-retrieve-download-or-streaming-url-using-api-calls

MPMoviePlayerController streaming video not play Audio on iPad

This may be a silly question. But, don't know where the problem actually. I'm trying to stream my http streaming (HLS) through MPMoviePlayercontroller video streaming is fine. But, audio isn't working on real device (Working in Simulator) Here is my code,
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"http://mydomain:1935/coder/%#/playlist.m3u8", self.streamField.text]];
theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:url];
theMoviPlayer.controlStyle = MPMovieControlStyleFullscreen;
theMoviPlayer.movieSourceType = MPMovieSourceTypeStreaming;
theMoviPlayer.view.transform = CGAffineTransformConcat(theMoviPlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
UIWindow *backgroundWindow = [[UIApplication sharedApplication] keyWindow];
[theMoviPlayer.view setFrame:backgroundWindow.frame];
[backgroundWindow addSubview:theMoviPlayer.view];
[theMoviPlayer play];
Has anyone worked on this? I'm getting only with device for audio issue.
Edit
I have tried below one,
NSURL *url = [NSURL URLWithString:#"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[self presentMoviePlayerViewControllerAnimated:player];
This(URL only given to safari) works fine both iPad and Simulator iPad of Safari browser with Audio. But, not working as application on iPad except Simulator.
First add AVFoundation.framework and add below code.
in .h file
#import <AVFoundation/AVFoundation.h>
and .m file
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];

Live Streaming in iOS

I would like to implement live streaming in iOS app, i found some suggestions to convert and play already recorded videos, but i need to implement direct live streaming video from iPhone/Webcam to iOS App.
How to convert webcam/iPhone or any other recording video to .M3U8?, How to send this video to Server?
Please give me some suggestions and tutorials. Thanks
use MPMoviePlayerController
NSURL *mediaURL = [NSURL URLWithString:#"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:mediaURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
[mp setControlStyle:MPMovieControlStyleFullscreen];
[mp setMovieSourceType:MPMovieSourceTypeStreaming];
[mp setFullscreen:YES];
[self.view addSubview:[mp view]];
[mp prepareToPlay];
[mp play];
For youtube streams, you can use youtube-ios-player-helper lib.
https://github.com/youtube/youtube-ios-player-helper

iOS: HTTP Live Streaming to app, Video won't play

I'm have some video files ready for streaming on my server. Here's the code I'm trying to use to play them in an iOS app:
Video *vid = [videos objectAtIndex:index];
NSURL *vidUrl = [NSURL URLWithString:vid.videoUrl];
NSLog(#"%#",vid.videoUrl);
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:vidUrl];
player.controlStyle=MPMovieControlStyleEmbedded;
[player.view setFrame:self.view.bounds];
[self.view addSubview:player.view];
[player play];
If I copy and paste the URL the NSLog spits out into Safari, the video plays fine. So I know the URL is good. But in my app, I just get a black screen. What's wrong with my code?
MPMoviePlayerController needs to be a strong property declared as so #property (strong, nonatomic) MPMoviePlayerController *mvpc;
Then whenever you want to play a movie you would write:
self.mvpc = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:#"movieURL"]];
self.mvpc.shouldAutoplay = YES; //Optional
self.mvpc.controlStyle = MPMovieControlStyleEmbedded;
[self.mvpc prepareToPlay];
[self.mvpc.view setFrame:self.view.bounds];
[self.view addSubview:self.mvpc.view];
[self.mvpc play];

Resources