3

I'm making a new menu for the rules in my card game and I want to add some music to liven the menu up.

I've already tried some code that i saw here on stackoverflow (here's the link How to get music to play in Delphi 7?).

Here's my code so far for the menu

procedure TfrmRules.FormActivate(Sender: TObject);
begin
  mpMusic.FileName:='1-33 Select.mp3';
  mpMusic.Open;
  mpMusic.Play;
end;

I expected it to play the song but it gave me a debugging message and nothing played.

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
PrimeBeat
  • 444
  • 5
  • 15
  • I don't have Delphi 2010, but I tried your code in both Delphi 7 and Delphi XE7, and it works in both so I'm pretty sure it works on Delphi 2010 also. Now we just need to find out what is different in your application / system. Create a new application, add a `TButton` and a `TMediaPlayer` to the form. Then enter the code from above to the `OnClick` handler for the button. If it doesn't play the sound, edit your question and add the whole form code to your question. – Tom Brunberg Aug 03 '19 at 12:39
  • You need to do some basic troubleshooting here. Is the file in the same folder as your application? If not, you need to specify the full path name in addition to the filename. Does the file play in Windows Media Player? If not, it may be corrupt or you may not have the proper codec installed. Can you play a different file, like one of the .wav files that come with Windows using that code? – Ken White Aug 03 '19 at 15:41
  • @KenWhite It is in the same folder, I also just checked that it could play on windows media player and it did,I also played a other mp3 file in the program and it worked perfectly. – PrimeBeat Aug 03 '19 at 17:48

0 Answers0