Tobeash
Tobeash
CC#
Created by Tobeash on 3/21/2024 in #help
Best C# course for intermediate programmer to get employment?
I can solve leetcode problems with c# and have some awareness of mvvm and ppf and winforms as I did some basic projects with them but I would like to get up with current standarts in the language and what it is being used for to achieve employment coding with it as it seems like a cool comfortable language to code in Looking for a course I could complete that would make me atractive for employment just so I can quickly jump in and do what is required of me, understanding and being able to use current industry trandarts
40 replies
CC#
Created by Tobeash on 10/18/2023 in #help
❔ 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
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream stream = assembly.GetManifestResourceStream("Pomodoro.Music.taskdone2.wav");
System.Media.SoundPlayer player = new System.Media.SoundPlayer(stream);
player.Play();

try
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"Music\taskdone2.wav");
//SoundPlayer player = new SoundPlayer(audioStream);
player.Play();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}


string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Music\\taskdone2.mp3");
MediaPlayer player = new MediaPlayer();
player.Open(new Uri(path, UriKind.Absolute));
player.Play();


string relativePath = @"./Music/taskdone2.mp3";
string absolutePath = Path.GetFullPath(relativePath);

MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.Open(new Uri(absolutePath, UriKind.Absolute));
mediaPlayer.Play();
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream stream = assembly.GetManifestResourceStream("Pomodoro.Music.taskdone2.wav");
System.Media.SoundPlayer player = new System.Media.SoundPlayer(stream);
player.Play();

try
{
System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"Music\taskdone2.wav");
//SoundPlayer player = new SoundPlayer(audioStream);
player.Play();
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}


string path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Music\\taskdone2.mp3");
MediaPlayer player = new MediaPlayer();
player.Open(new Uri(path, UriKind.Absolute));
player.Play();


string relativePath = @"./Music/taskdone2.mp3";
string absolutePath = Path.GetFullPath(relativePath);

MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.Open(new Uri(absolutePath, UriKind.Absolute));
mediaPlayer.Play();
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
11 replies