【发布时间】:2009-07-17 09:21:17
【问题描述】:
我还需要能够控制它的音量。 另外,如何控制系统音量,以检测低音量或静音状态?
【问题讨论】:
我还需要能够控制它的音量。 另外,如何控制系统音量,以检测低音量或静音状态?
【问题讨论】:
使用 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;
【讨论】:
看看这篇文章:Your first MP3 Delphi player。它使用 TMediaPlayer 来播放 mp3 文件。不完全是你想要的,但是一个很好的起点。
【讨论】:
只需使用 MM api(MSDN 和 google 上的大量示例)
【讨论】:
char *mp3FilePath = ... ;
char *workingDirPath = ... ;
ShellExecute(hwnd, "open", mp3FilePath, NULL, workingDirPath, SW_SHOWNORMAL);
【讨论】: