0

I am using below code to play mp3 file from some url (https://domailname/a.mp3), this server required jwt token for authenticating the request.

how can i play the audio from any url which requires authentication

 System.Uri manifestUri = new Uri("https://domailname/a.mp3");
        mediaPlayerElement.Source = MediaSource.CreateFromUri(manifestUri);

        mediaPlayerElement.MediaPlayer.Play();
Rahul Somwanshi
  • 455
  • 2
  • 5
  • 19

1 Answers1

0

You may put the token in the URL as a query parameter if under under the following circumstances described on this thread.

System.Uri manifestUri = new Uri("https://domailname/a.mp3/?jwt=jwttoken");

MediaSource instance can create from AdaptiveMediaSource. If the media is adaptive source you may try to create a AdaptiveMediaSource by CreateFromUriAsync(Uri, HttpClient) method firstly. Put the token as value of Authorization Header using the bear schema, and add the header to HttpClient by the DefaultRequestHeaders property. For this you may reference the scenario 3 of AdaptiveStreaming official sample.

Community
  • 1
  • 1
Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21