views:

700

answers:

6

I need also to be able to control its volume. Also, how do I control system sound volume, to detect low volume, or mute states ?

+4  A: 

Check this question : http://stackoverflow.com/questions/246723/how-to-play-a-wav-file-in-delphi It will give you some idea.

Shoban
A: 
char *mp3FilePath    = ...   ;
char *workingDirPath = ...   ;
ShellExecute(hwnd, "open", mp3FilePath, NULL, workingDirPath, SW_SHOWNORMAL);
RED SOFT ADAIR
He said 'with no associated application'...
Martijn
+2  A: 

Use Shoban's link for how to play sound.

Here's how to control the sound volume for devices:

uses MMSystem;

type
   TVolumeRec = record
     case Integer of
       0: (LongVolume: Longint) ;
       1: (LeftVolume, RightVolume : Word) ;
     end;

const DeviceIndex=5
       {0:Wave
        1:MIDI
        2:CDAudio
        3:Line-In
        4:Microphone
        5:Master
        6:PC-loudspeaker}

procedure SetVolume(aVolume:Byte) ;
var 
  Vol: TVolumeRec;
begin
   Vol.LeftVolume := aVolume shl 8;
   Vol.RightVolume:= Vol.LeftVolume;
   auxSetVolume(UINT(DeviceIndex), Vol.LongVolume) ;
end;

function GetVolume:Cardinal;
var 
  Vol: TVolumeRec;
begin
   AuxGetVolume(UINT(DeviceIndex),@Vol.LongVolume) ;
   Result:=(Vol.LeftVolume + Vol.RightVolume) shr 9;
end;
Martijn
+2  A: 

If this is for non-commercial use, the BASS libraries are free and give you the control you're looking for.

There are free video tutorials on 3DBuzz, one of which is creating your own MP3 player. They're in the Video Category list on the front page.

Bruce McGee
A: 

Just use MM apis (tons of samples on MSDN and google)

MM ? what API is that ?
Jlouro
+1  A: 

Have a look at this article: Your first MP3 Delphi player. It uses TMediaPlayer to be able to play mp3 files. Not exactly what you want, but a very good starting point.

Alister