Question Getting URL from Properties.Resources

Hamzyah

New member
Joined
Jul 7, 2021
Messages
4
Programming Experience
3-5
Hello, I am having problem with getting url path of sound effect from Properties.Resources. When I am working on app for myself it is easy I just copy full file path for example “C:/videos/.....”. But I am working for app that will be used on another computers, and that filepath doesn’t match target computers, so I need to use Properties.Resources.FileName. The file is wav and mp3, and it works when I use SoundPlayer in c#. But I need to use axWindowsMediaPlayer, and when I type axWindowsMediaPlayer.URL = Properties.Resources.FileName; It doesnt work, any solutions please?
 
Well, you're passing in a filename to a property which is expecting to get a URL. Why are you surprised that it is not working?
 
Well, you're passing in a filename to a property which is expecting to get a URL. Why are you surprised that it is not working?
I am not surprised that it isn’t working, I am trying to find put how to connect my wav song or mp3 song from Resources to axWindowsMediaPlayer.
 
Most URLs for local files will have a "file://" prefix.

Thank you, I know how local files work, and with them my app is working perfectly. But my job isn’t to use path of local file, because it will work just on my computer. I need to use path from poject resources, so when I send my app to someone, it can work perfectly. I figured it out for SoundPlayer. When using soundplayer, in file path, I just put Properties.Resources.filename; and it works perfectly, but here I need to use axWindowsMediaPlayer, and for it method I used for SoundPlayer doesn’t work, it says that there is problem because something can’t be converted to ‘string’. And I know that it is problem, but I am just trying to find someone who will tell me how to connect my axWindowsMediaPlayer to file using app directory path and not path in my computer. I hope you understand it is simple.
 
Post your code in code tags, as well as the exact error you are getting. No screenshots, please. Do not summarize or paraphrase.

Is it a compiler time error or a runtime error?
 
Post your code in code tags, as well as the exact error you are getting. No screenshots, please. Do not summarize or paraphrase.

Is it a compiler time error or a runtime error?
Thank you for your time and effort to help me, you are the best, and I found solution using my logic ?. It works and that’s only which is important. For axWindowsMediaPlayer.URL, I used this:
C#:
axWindowsMediaPlayer.URL = Application.StartupPath + “/resources/myfilename.wav”;
and this kind of locating file, works on every computer.
 
Last edited by a moderator:
It works and that’s only which is important. For axWindowsMediaPlayer.URL

That's because the people who made the axWindowsMediaPlayer library were idiots. They used an improper variable name to define the type to be something its not. The parameter you are using works because the address of the value URL is not a url at all; but a string. Its not even defined as a uri. This allows you to use any relative address providing its built correctly. How you built your path is poor. Recommending Path.Combine be used instead.
 
Back
Top Bottom