简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM