Play live URL streaming by AVPlayer - ios

MY Real URL => "http://125.209.70.43:1500/"
As my title said that I want to play music from my live streaming URL. I tried with following code. (following URL is for testing not real)
[self playSelectedSong:#"http://media-ice.musicradio.com/HeartPlymouthV1"]; // custom method with testing URL
Code of method.
-(void)playSelectedSong:(NSString *) urlString
{
self.songPlayer = [[AVPlayer alloc]initWithURL:[NSURL URLWithString:urlString]];;
[self.songPlayer play];
}
I have Question like.
1) What should proper URL Pattern? is streaming URL has any rules about its pattern or not ?
For example above code is woking for streaming URL (NOT mine url) such like,
1) http://108.178.57.196:11112/los40principales
2) http://media-ice.musicradio.com/HeartPlymouthV1
BUT in my URL it is not working (for iOS Devices), my URL pattern is
http://125.209.70.43:1500/
My streaming URL pattern looking like above.
Then how can I play music by using above URL ? My above code is not working for http://125.209.70.43:1500/. Anybody have issue related as a mine ?
Please help me on this issue.
NOTE: My URL is correct and its working, I checked with vlc media player network streaming. by
=> VLC Medial Player
-> File Menu
-> Open Network
-> URL set as "http://125.209.70.43:1500/"
-> click on "Open" button.
Try with above step it's working very well.

Your stream is Windows Media Audio, that's not going to work with AVPlayer. If you want to support streaming to iOS devices, check out https://developer.apple.com/streaming/

Related

Playing a Live Stream with AVPlayer

I was trying to play a live stream with AVPlayer. And I somewhat succeeded. My question is, if I play an URL that ends with m3u8 I can, however, when I try a link that doesn't (see example below) I can't! Same behavior when I try to open them with Safari, but on VLC, they both work. Why is that? Unsupported codec?
Examples:
This works: https://fluxustv.blogspot.com#bit.ly/fluxusfish?.m3u8
This doesn't: http://www.tvworldfree.ga:3000/p002/p158156/2219
The link without “m3u8” is a raw transport stream. AVPlayer does not support that format without a manifest.

Play audio file stored in google drive (remote URL) - Swift

I'm using AVPlayer to play audios which are stored in google drive. Problem is that as public link of files stored in google drive don't have extension mentioned, that's why AVPlayer doesn't play audio because cannot get its extension from URL. Following is code i'm using.
let url = URL(string: "https://drive.google.com/file/d/1n6GeWY11Txvou5K-Tl7Ju39fQsWQTDvR/view?usp=sharing")
let playerItem:AVPlayerItem = AVPlayerItem(url: url!)
player = AVPlayer(playerItem: playerItem)
player!.play()
For example, in case of following url
https://drive.google.com/file/d/1n6GeWY11Txvou5K-Tl7Ju39fQsWQTDvR/view?usp=sharing
AVPlayer isn't playing it and showing it's duration to 0.
But when i play audio file like following
https://www2.cs.uic.edu/~i101/SoundFiles/BabyElephantWalk60.wav
it plays without any problem because of file extension available.
So, could someone please comment how to play audio when extension not available in remote URLs.
Thanks
Just got to modify the URL, Use this:
https://drive.google.com/uc?export=open&id=1n6GeWY11Txvou5K-Tl7Ju39fQsWQTDvR
Here's what I did,
Sharing an audio file looks like this:
https://drive.google.com/file/d/XXXXXXXXXXXXXXXXXX/view?usp=sharing
XXXXXXXXXXXXXXXXXX is the file ID. You can access the direct file by getting rid of everything after the ID and replacing file/d/ with uc?export=open&id=
Keep in mind, if Google decide to change the way their file sharing works then this solution may break.

Streaming video hosted in Azure Media Services on iOS (Xamarin)

I have a video hosted in Azure Media Services. I have encoded the video using the H264 Multiple Bitrate 1080p Encoding preset (I've tried others as well). After publishing for streaming I get the following endpoints. (I replaced my actual site name with mysite below)
Smooth Streaming
http://mysite.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest
MPEG-DASH
http://mysite.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest(format=mpd-time-csf)
HLS(v3)
http://mysite.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest(format=m3u8-aapl-v3)
HLS(v4)
http://mysite.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest(format=m3u8-aapl)
I have successfully streamed the video for android using the HLS(v4) url, so I know the video works.
For ios I followed this tutorial. https://developer.xamarin.com/recipes/ios/media/video_and_photos/play_a_video_using_avplayer/
I could successfully play a local video. I also was able to play a remote video following this apple tutorial. https://developer.apple.com/library/prerelease/content/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html
There must be something wrong with the URL I'm using, but I can't figure out what it is. Here is the code in my ViewDidLoad method.
var myUrl = NSUrl.FromString("http://myurl.streaming.mediaservices.windows.net/eaaa9f34-e39a-4393-a93b-14a7609ebd27/sampleVid.ism/manifest(format=m3u8-aapl)");
var appleUrl = NSUrl.FromString("http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8");
_playerItem = new AVPlayerItem(myUrl);
_player = new AVPlayer(_playerItem);
_playerLayer = AVPlayerLayer.FromPlayer(_player);
_playerLayer.Frame = ProfileVideoContainerView.Frame;
ProfileVideoContainerView.Layer.AddSublayer(_playerLayer);
_player.Play();
myUrl does not work, but appleUrl does.
It turns out I just needed to use https instead of http. I thought I had tried this, but apparently not. Also, I'm not sure why the appleUrl works with http.
There is an iOS "feature" that disallows a connection to an http endpoint unless the endpoint is listed in the info.plist as an allowed unsecured connection. I had forgotten about this and got caught by it a few days/weeks ago. I think this feature was implemented with iOS9, but am not 100% sure on this. It may have been implemented before then.

cloudfront video streaming not working on ios devices

I am trying to stream the video on IOS devices using amazon cloudfront web distribution(RTMP streaming is not supported by apple devices) and video is stored in s3 .Moreover the link is accessible to everyone.When I try to paste the video link in browser the video starts to download instead of streaming.
After inspecting on instagram's websites I came to know that instagram does the same thing(maybe) but the difference is it uses akamai CDN and I am using amazon's cloudfront
My link:
http://d16jy53srxox6v.cloudfront.net/brown.mp4
Instagram video streaming link:
https://igcdn-videos-b-2-a.akamaihd.net/hphotos-ak-xfa1/t50.2886-16/11773361_692383954227382_242786346_n.mp4
Where instagram video streams perfectly and my video gets download rather than streaming.After hitting google I found HLS is one of the solution yet I am looking for easy streaming alternative as my video max length would be 1 minute and HLS is good for larger files.Can anyone suggest me what should I do to make my video streamable without HLS?
Morover I tried to stream it in ios device but it tries to download and then plays it.Heres my code:
-(IBAction)click:(id)sender
{
// Make a URL
NSURL *url = [NSURL URLWithString:
#"http://d16jy53srxox6v.cloudfront.net/brown.mp4"];
// Initialize the MPMoviePlayerController object using url
_videoPlayer = [[MPMoviePlayerController alloc]
initWithContentURL:url];
// Set control style to default
_videoPlayer.controlStyle = MPMovieControlStyleDefault;
// Set shouldAutoplay to YES
_videoPlayer.shouldAutoplay = YES;
_videoPlayer.movieSourceType=MPMovieSourceTypeStreaming;
// Add _videoPlayer's view as subview to current view.
[self.view addSubview:_videoPlayer.view];
// Set the screen to full.
[_videoPlayer setFullscreen:YES animated:YES];
}
Problem Might be the content type of the uploaded video
You can go to the s3 bucket and check the metadata field under properties tab
I faced the same issue with one of my videos on s3 it used to get downloaded instead of playing it.
I resolved this issue by adding metadata to the video as
Content-Type = video/mp4
hope this helps

using livestream video in iOS application

I want to use video from some live streaming channel i.e. twitch, youtube in my iOS application without using their plugins. How can i do so?
I'm trying to get url of the video so that i can play it via moviePlayer or something else in my application. At the moment, i'm using OBS for uploading the live-stream on twitch.tv
I've found the following link, but again i'm unable to find the url of the video so can't use the solution mentioned How can I use Livestream player in iOS/Android app?
Thanks,
I have solved the issue using webView. For Youtube we've stream id and we put it in url as "https://www.youtube.com/watch?v=videoId".
For ustream i made url as "https://www.ustream.tv/embed/channelId".
If you don't want to use webView then you can use helper libraries for these platforms i.e. YTPlayer, twitch etc.

Resources