1
SoundPlayer player = new SoundPlayer();
player.SoundLocation =  "C:\\Users\\tamar\\Documents\\Visual Studio 2010\\Projects\\The legend of Omoor\\The legend of Omoor\\challenger.wav";

SoundPlayer player2 = new SoundPlayer();
player2.SoundLocation = "C:\\Users\\tamar\\Documents\\Visual Studio 2010\\Projects\\The legend of Omoor\\The legend of Omoor\\challenger.wav";

Console.WriteLine("The legend of Omoor!");
Console.WriteLine("Press any letter to continue.");
Console.ReadLine();

player.Play();

char a;
Console.WriteLine("Click 'x' to use special move: Arad!");
a = char.Parse(Console.ReadLine());

if (a == 'x')
{
    player2.Play();//that's the part where nothing works, neither the first music, nor the second.
}

the music starts playing after I press "any letter to continue". the problem is that the music stops once I choose x, and it doesn't play the new music that I put in the 'if' too. even without the player2.Play(); in the if, it won't play anything.

omoor
  • 73
  • 8
  • 2
    Maybe it stops because you leave the program after that? What's below your current code? What does it do if you chose any other letter? – Rafalon Jan 06 '21 at 10:14
  • Does the same thing happen with an `if (true)`? – fdcpp Jan 06 '21 at 10:17
  • How will you know if it changed when both song files are the same file??? **(1)** No way to do `player.Stop();` before doing `player2.Play();`? **(2)** Are you getting any errors or warning in compiler? **(3)** You don't have any _"press `"any letter to continue"`"_ code showing so maybe you've got other code elsewhere that causes an error and the program stops. – VC.One Jan 06 '21 at 10:22
  • hey Rafalon, if I choose any other letter, it still doesn't work. – omoor Jan 06 '21 at 10:26
  • hey fdcpp, if(true) doesn't work as well. – omoor Jan 06 '21 at 10:28
  • Hey VC.One, (1) it still doesn't play player2's music.(2)no errors, no warnings.(3) I edited it, now I do have it, it wasn't in the code for some reason. – omoor Jan 06 '21 at 10:39
  • 1
    What happens if you add a `Console.ReadLine();` at the end of your code? As I said in my first comment, I suspect that when you press that second letter, your code enters the `if` (or not depending on the letter), then your program terminates immediately, which is why you say "*it won't play anything*". – Rafalon Jan 06 '21 at 11:41
  • 1
    Possible duplicate of [Why is the console window closing immediately once displayed my output?](https://stackoverflow.com/questions/8868338/why-is-the-console-window-closing-immediately-once-displayed-my-output) – Rafalon Jan 06 '21 at 11:48
  • Omg! Rafalon! it worked!!! thank you so much! – omoor Jan 06 '21 at 11:50
  • Rafalon, it is indeed a duplicate of that, the code is over, so it's done running it, and so it stops! thanks again, i'l mark the question as answered now! – omoor Jan 06 '21 at 11:53

0 Answers0