MediaSource.CreateFromUri() cannot retrieve the file.

jigyanshu 21 Reputation points

Here is my code........

var mediaPlayer = new MediaPlayer();
mediaPlayer.IsLoopingEnabled = true;
var soundPath = "D:\Documents\comunit\WinCom\Phonemar\otCom\bin\x86\Debug\AppX\Assets\Sound\ringing_tone.mp3"
mediaPlayer.Source = MediaSource.CreateFromUri(new Uri(soundPath));
catch (FileNotFoundException fex)
System.Diagnostics.Debug.WriteLine("{0} : {1}", DateTime.Now.ToString(), fex.Message);
catch (Exception ex)
System.Diagnostics.Debug.WriteLine("{0} : {1}", DateTime.Now.ToString(), ex.Message);

Crashing error message - System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)

This crash is happened rendering. Whats the problem with this? I am using mediaplayer for MediaPlayer.Source . How can I get proper MediaSource using my first method? Help me please.

Universal Windows Platform (UWP)
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,223 questions
0 comments No comments
{count} votes

Accepted answer
  1. Roy Li - MSFT 31,681 Reputation points Microsoft Vendor


    Welcome to Microsoft Q&A!

    Are you trying to play the mp3 file that you added to the Assets folder? If it is, then the issue is caused by your URI.
    You could not pass the file path parameter to CreateFromUri directly. In general, the Uri parameter is HTTP protocol address such as But you could assign some the file path with UWP file access URI scheme.
    If you want to access the Assets folder in your project, you could try to use the following Uri:

    var soundPath = "ms-appx:///Assets/xxxxxx/xxx.mp3";  

    Thank you.

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

1 additional answer

Sort by: Most helpful
  1. Castorix31 81,636 Reputation points

    Use "\" in your path or @ :

    var soundPath = @"D:\Documents\comunit\WinCom\Phonemar\otCom\bin\x86\Debug\AppX\Assets\Sound\ringing_tone.mp3";
    0 comments No comments