简体   繁体   English

流式传输托管在iOS(Xamarin)上的Azure媒体服务中的视频

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

I have a video hosted in Azure Media Services. 我在Azure媒体服务中托管了一个视频。 I have encoded the video using the H264 Multiple Bitrate 1080p Encoding preset (I've tried others as well). 我已经使用H264多比特率1080p编码预设对视频进行了编码(我也尝试过其他方法)。 After publishing for streaming I get the following endpoints. 发布流媒体后,我得到以下端点。 (I replaced my actual site name with mysite below) (我将实际的网站名称替换为下面的mysite

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. 我已经使用HLS(v4)网址成功流式传输了适用于Android的视频,因此我知道该视频可以正常工作。

For ios I followed this tutorial. 对于ios,我遵循了本教程。 https://developer.xamarin.com/recipes/ios/media/video_and_photos/play_a_video_using_avplayer/ 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 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. 我使用的URL一定有问题,但我不知道它是什么。 Here is the code in my ViewDidLoad method. 这是我的ViewDidLoad方法中的代码。

        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. myUrl不起作用,但是appleUrl起作用。

It turns out I just needed to use https instead of http. 事实证明,我只需要使用https而不是http。 I thought I had tried this, but apparently not. 我以为我已经尝试过了,但是显然没有。 Also, I'm not sure why the appleUrl works with http. 另外,我不确定appleUrl为什么与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. 有一个iOS“功能”,它禁止与http终结点的连接,除非该终结点在info.plist中列为允许的不安全连接。 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. 我认为此功能是在iOS9上实现的,但对此并不是100%肯定。 It may have been implemented before then. 在此之前可能已经实现了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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