❔ How to play music files from resources/relative paths in wpf c# ?
I have spend good 2 to 3 hours trying to get a sound file played from relative path, it just doesnt work no matter what I try, I have tried mediaplayer, later found on stackoverflow it doesnt work from relative path so i switched to sounplayer, I have tried like 20 different codes lines I dont understand how is this so hard, is there like no support for playing sound?
what i tried
not even once was there a sound, only thing that worked was absolute path straight from c, which i dont know how could i use that for making an app that isnt always going to be in the same place
4 Replies
uhm... convert your paths to absolute paths? Like you already seem to know how to do?
I really don't understand the issue
there is something incredibly cursed with the pathing
C:\Users\name\OneDrive\Desktop\code\C#\Pomodoro\Pomodoro\bin\Debug\net6.0-windows\
is my base directory
there is no music no resources files despite everything online saying there should be stuff
so everytime i try to access my recourses and actually connect the two it just doesnt work
the music folder is ins
C:\Users\name\OneDrive\Desktop\code\C#\Pomodoro\Pomodoro\Music
and they are not getting copied despite being set to resources and copy always
mkay you have to use embledebebded resources to actually get the folder copied to trhe bin folder so that the program can work it
don't do embedded resource, no
that one should cause the resource file to be encoded directly into the compiled DLL/EXE
which you can then write code to extract at runtume
all you need to do is set the "Copy to Output" flag on all those files, which you should be able to do, regardless of what compile action they're set to
the most sensible compile action would be simply "Content"
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.