我还需要能够控制其音量。 另外,如何控制系统音量、检测低音量或静音状态?
最佳答案
使用 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;
关于delphi - 如何在没有关联应用程序的情况下直接播放声音文件(mp3、wav 等)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1142231/