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 ?
views:
700answers:
6
+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
2009-07-17 09:25:05
A:
char *mp3FilePath = ... ;
char *workingDirPath = ... ;
ShellExecute(hwnd, "open", mp3FilePath, NULL, workingDirPath, SW_SHOWNORMAL);
RED SOFT ADAIR
2009-07-17 14:26:25
He said 'with no associated application'...
Martijn
2009-07-17 14:48:42
+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
2009-07-17 14:55:26
+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
2009-07-17 17:13:08
+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
2009-07-19 22:17:35