How to play .ism/manifest file?

2019-09-15 06:39发布

问题:

I am developing the iOS app and wanted to play below file using Xamarin, but did not get any solution to play .ism/manifest file.

https://amssamples.streaming.mediaservices.windows.net/91492735-c523-432b-ba01-faba6c2206a2/AzureMediaServicesPromo.ism/manifest

I am using below code to play the audio file.

AVPlayer player = new AVPlayer ();
        var playerItem = (url != null) ? new AVPlayerItem(url) : null;
        player.ReplaceCurrentItemWithPlayerItem (playerItem);
        player.Play()

How to play this file?

回答1:

1) Your URL is missing (format=m3u8-aapl)

2) Do not let your AVPlayer go out of scope, hold a reference to it at the UIViewController level.

If you create an iOS project via the single view template, replace the ViewDidLoad method in the ViewController class with the following and your "audio" will play.

FYI: The URL is actually providing video also...

AVPlayer player;
public override void ViewDidLoad()
{
    base.ViewDidLoad();
    var url = new NSUrl("https://amssamples.streaming.mediaservices.windows.net/91492735-c523-432b-ba01-faba6c2206a2/AzureMediaServicesPromo.ism/manifest(format=m3u8-aapl)");
    player = new AVPlayer();
    player.ReplaceCurrentItemWithPlayerItem(new AVPlayerItem(url));
    player.Play();                
}