加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 如何直接播放没有相关应用程序的声音文件(mp3,wav等)

发布时间:2020-12-15 09:50:46 所属栏目:大数据 来源:网络整理
导读:我还需要能够控制它的音量. 另外,如何控制系统音量,检测低音量或静音状态? 解决方法 使用Shoban的链接来播放声音. 以下是如何控制设备的音量: uses MMSystem;type TVolumeRec = record case Integer of 0: (LongVolume: Longint) ; 1: (LeftVolume,RightVo
我还需要能够控制它的音量.
另外,如何控制系统音量,检测低音量或静音状态?

解决方法

使用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;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读