0

I am developing iOS app, I am able to play the .ism/manifest file using below code (refer commented url), but my file is AES encrypted which requires bearer token to decrypt it. could you please let me know how to pass the bearer token to AVPlayer?

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=m//3u8-aapl)");
        var url = new NSUrl("https://amssamples.streaming.mediaservices.windows.net/830584f8-f0c8-4e41-968b-6538b9380aa5/TearsOfSteelTeaser.ism/manifest(format=m3u8-aapl)");
        audioPlayer = new AVPlayer();

        var keys = new object[] { "Authorization" };
        var objects = new object[] { "Bearer " + "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cm46bWljcm9zb2Z0OmF6dXJlOm1lZGlhc2VydmljZXM6Y29udGVudGtleWlkZW50aWZpZXIiOiI5ZGRhMGJjYy01NmZiLTQxNDMtOWQzMi0zYWI5Y2M2ZWE4MGIiLCJpc3MiOiJodHRwOi8vdGVzdGFjcy5jb20vIiwiYXVkIjoidXJuOnRlc3QiLCJleHAiOjE3MTA4MDczODl9.lJXm5hmkp5ArRIAHqVJGefW2bcTzd91iZphoKDwa6w8" };
        var dictionnary = NSDictionary.FromObjectsAndKeys(objects, keys);
        AVUrlAsset asset = new AVUrlAsset(url, dictionnary);

        audioPlayer.ReplaceCurrentItemWithPlayerItem(new AVPlayerItem(asset));
        audioPlayer.Play();
    }
Rahul Somwanshi
  • 455
  • 2
  • 5
  • 19
  • Actually you can do this via an `AVAssetResourceLoaderDelegate` that is applied to a `AVAssetResourceLoader` in order to provide your expiring token to allow Azure media services to do the AES decryption of the smooth stream. – SushiHangover May 25 '17 at 03:27
  • thanks Sushi, i am new to ios development, if you could provide me some sample code that would be really helpful to me. – Rahul Somwanshi May 25 '17 at 05:36

0 Answers0