(转)获取、设置系统音量演示程序
By
admin
at 2018-08-04 • 1人收藏 • 1205人看过
import win.ui; /*DSG{{*/ var winform = win.form(text="获取、设置系统音量演示程序";right=896;bottom=662) winform.add( static={cls="static";left=32;top=16;right=880;bottom=601;bgcolor=0;db=1;dl=1;dr=1;dt=1;edge=1;z=1}; static2={cls="static";text="系统音量:";left=112;top=624;right=216;bottom=648;align="right";db=1;dl=1;transparent=1;z=3}; trackbar={cls="trackbar";left=224;top=616;right=680;bottom=646;db=1;dl=1;dr=1;max=100;min=0;z=2} ) /*}}*/ import web.form; var wb = web.form(winform.static) wb.go("https://html5media.info/") winform.show(); import sys.audioVolume; var volumeCtrl = sys.audioVolume(); winform.trackbar.setRange(0,100); winform.trackbar.pos = volumeCtrl.volume; winform.trackbar.oncommand = function(id,event,pos){ if( event == 8/*_SB_ENDSCROLL*/ ){ volumeCtrl.volume = winform.trackbar.pos; } elseif( event == 5/*_SB_THUMBTRACK*/) { volumeCtrl.volume = pos; } } winform.show(true) win.loopMessage();
其中的
sys.audioVolume;
库代码为:
import util.metaProperty; namespace sys; class audioVolume { ctor(){ this.handle = _dll.CreateVolumeCtrlP(); ..table.gc(this,"delete") }; delete = function(){ if(this.handle){ _dll.DeleteVolumeCtrl(this.handle); this.handle = null; } }; @_metaProperty; } namespace audioVolume { _dll = ..raw.loadDll($"~\lib\sys\audioVolume\.res\volumeCtrl2.dll",,"cdecl"); _metaProperty = ..util.metaProperty( volume = { _get = function(){ if(owner.handle) return _dll.GetVolume(owner.handle); } _set = function(v){ if(owner.handle)return _dll.SetVolume(owner.handle,v); } }; mute = { _get = function(){ if(owner.handle) return _dll.GetMuteB(owner.handle); } _set = function(v){ if(owner.handle)return _dll.SetMute(owner.handle,v); } }; ) } /**intellisense() sys.audioVolume = 系统音量控制 sys.audioVolume() = 创建音量控制对象\n!stdSysAudioVolume. !stdSysAudioVolume.volume = 获取或设置系统音量,\n最小值为0,最大值为1 !stdSysAudioVolume.mute = 获取或设置是否静音 end intellisense**/
保存以备用,谢谢jacen提供,
aar官方网址:http://bbs.aardio.com/forum.php
登录后方可回帖