© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
2 replies
d56Wr

❔ C# WPF playing background music

Hello, I have WPF app for game launcher/updater. I wanted to add background music, so I added this code to my UI.xaml:
<MediaElement Name="backgroundMusicPlayer" LoadedBehavior="Play" Visibility="Hidden" Source="../Resources/Music/theme.mp3"/>
<MediaElement Name="backgroundMusicPlayer" LoadedBehavior="Play" Visibility="Hidden" Source="../Resources/Music/theme.mp3"/>


In Visual Studio it works as expected, the music is being played. But if I build the solution, music is not playing.
The "theme.mp3" resource has Build Action = Resource and Copy to Output Directory = Do not copy, since I need the mp3 inside the exe.

Could someone point me to what I'm doing wrong? Thank you!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ c# wpf change background color of whitespace character
C#CC# / help
3y ago
c# wpf style
C#CC# / help
11mo ago
Music in my wpf project?
C#CC# / help
2y ago
WPF ContextMenu background color problems
C#CC# / help
2y ago