我还需要能够控制它的音量。另外,如何控制系统音量,以检测低音量或静音状态?
发布于 2009-07-17 14:55:26
使用Shoban的链接了解如何播放声音。
下面是如何控制设备音量的方法:
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;发布于 2009-07-17 17:13:08
发布于 2009-07-19 22:17:36
看看这篇文章:Your first MP3 Delphi player。它使用TMediaPlayer来播放mp3文件。这不完全是你想要的,但却是一个很好的起点。
https://stackoverflow.com/questions/1142231
复制相似问题