question

AndrewAllen-6526 avatar image
0 Votes"
AndrewAllen-6526 asked ·

UnauthorizedAccessException using MediaPlayerElement UWP control

I am trying to play a mpeg dash video stream hosted in a gninx on a UWP application (Windows 10) with MediaPlayerElement control, but I keep getting the status ManifestDownloadFailure and a System.UnauthorizedAccessException.

alt text

This is the method that I'm using:

 private async void Button_Click(object sender, RoutedEventArgs e)
     {
         if (!string.IsNullOrEmpty(url.Text))
         {
             AdaptiveMediaSourceCreationResult result = await AdaptiveMediaSource.CreateFromUriAsync(new Uri(url.Text));
    
             if (result.Status == AdaptiveMediaSourceCreationStatus.Success)
             {
                 var ams = result.MediaSource;
                 mediaPlayerElement.Source = MediaSource.CreateFromAdaptiveMediaSource(ams);
             }
         }
     }

am I missing something?


windows-uwp
wstk4.png (24.1 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RichardZhang-MSFT avatar image
0 Votes"
RichardZhang-MSFT answered ·

Hello,​

Welcome to our Microsoft Q&A platform!

Is your url a local path? For example D: \test.mp4. If so, UWP does not have permission to access files directly through the path.

UWP has strict management of file access permissions. You can only access your application folder and project folder through the path.

A more recommended workflow is that you use FileOpenPicker to select a file and then create a MediaSource form the file.

Get file

 public async static Task OpenLocalFile(params string[] types)
 {
     var picker = new FileOpenPicker();
     picker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
     foreach (var type in types)
     {
         picker.FileTypeFilter.Add(type);
     }
     var file = await picker.PickSingleFileAsync();
     return file;
 }

Use

 private async void Button_Click(object sender, RoutedEventArgs e)
 {
     var file = await OpenLocalFile(".mp4");
     if(file != null)
     {
         mediaPlayerElement.Source = MediaSource.CreateFromStorageFile(file);
     }
 }

Thanks

· 4 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Richard, thanks for the answer, no in this case I am trying to play a url, this url points to a MPEG DASH .mpd file hosted in a nginx server with a urn:mpeg:dash:profile:full:2011 profile. I saw here that this profile is compatible with the UWP mediaPlayerElement control, but a keep getting the UnauthorizedAccessException.

By the way, when a try to play the same url in a web player that I have, it plays ok



0 Votes 0 · ·

Hi,

I saw the urn:mpeg:dash:profile:full:2011 profile is under the Unsupported DASH profiles subtitle, Did you use an unsupported profile?

0 Votes 0 · ·

Hi, Sorry to bother you, did my reply solve your problem? Do you have any questions about this issue?

0 Votes 0 · ·

Hello, is there any new information in your question, and can we provide you with new help?

0 Votes 0 · ·