So I'm trying to code this random UI thing for practice, and I want to play an mp3 file, but can't seem to actually hear the file. Yes, I have speakers, and yes they work. The file seems to be playing, but doesn't produce any audio output on my computer. I couldn't seem to find another post or question that was answered that actually helped.
It may be a hardware issue and not the code, I'm not sure though
class Program
{
string keyChoice = Console.ReadLine();
static void Main(string[] args)
{
Console.WriteLine("Hello,[user]!");
Console.WriteLine("Please Enter Your Username");
Console.WriteLine();
string uname = Console.ReadLine();
Thread.Sleep(600);
Console.Clear();
Thread.Sleep(600);
Console.WriteLine("Welcome to Axiom, " + uname);
Console.WriteLine("If You Want To Find The Full List Of Commands, Please Press 1");
Console.WriteLine();
while (true)
{
string keyChoice = Console.ReadLine();
switch (keyChoice)
{
case "1":
Thread.Sleep(600);
Console.Clear();
Thread.Sleep(600);
Console.WriteLine("Console Commands:");
Console.WriteLine("Press '2' To Get 1000$ FREE");
Console.WriteLine("Press '3' To Pick Command 3");
Console.WriteLine();
Console.WriteLine("Press '0' To Exit Or Press A Command Button To Execute A Command");
Console.WriteLine();
continue;
case "2":
Thread.Sleep(600);
Console.Clear();
Thread.Sleep(600);
Console.WriteLine("Get Messed Up");
WindowsMediaPlayer myplayer = new WindowsMediaPlayer();
myplayer.URL = "C:\\Users\\truale\\Desktop\\RickRoll";
myplayer.controls.play();
//This is where I want to add the file. To rickroll someone of course
continue;
case "3":
Thread.Sleep(600);
Console.Clear();
Thread.Sleep(600);
Console.WriteLine("You Chose Command 3");
Console.WriteLine();
Console.WriteLine("Press '0' To Exit Or Press A Command Button To Execute A Command");
Console.WriteLine();
continue;
case "0":
Thread.Sleep(600);
Console.Clear();
Thread.Sleep(600);
return;
default:
Thread.Sleep(600);
Console.Clear();
Thread.Sleep(600);
Console.WriteLine("Input Not Valid");
Console.WriteLine();
Console.WriteLine("Press '0' To Exit Or Press A Command Button To Execute A Command");
Console.WriteLine();
continue;
The problem is in the file path.
We have to add extension like.mp3 or the file's own extension such as:
myplayer.URL = "C:\\Users\\truale\\Desktop\\RickRoll.mp3";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.