我在 Azure 媒体服务中托管了一个视频。我使用 H264 多比特率 1080p 编码预设对视频进行了编码(我也尝试过其他预设)。发布流媒体后,我得到以下端点。 (我用下面的 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)
我已经使用 HLS(v4) url 成功地为 android 流式传输了视频,所以我知道视频有效。
对于 ios,我遵循了本教程。 https://developer.xamarin.com/recipes/ios/media/video_and_photos/play_a_video_using_avplayer/
我可以成功播放本地视频。我也能够按照这个苹果教程播放远程视频。 https://developer.apple.com/library/prerelease/content/documentation/AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html
我使用的 URL 一定有问题,但我无法弄清楚它是什么。这是我的 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 不起作用,但 appleUrl 起作用。
最佳答案
原来我只需要使用 https 而不是 http。我以为我已经尝试过了,但显然没有。另外,我不确定为什么 appleUrl 与 http 一起使用。
关于ios - 在 iOS (Xamarin) 上的 Azure 媒体服务中托管的流式视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42034719/