本帖最后由 jiashuang 于 2014-4-11 19:25 编辑
下面代码有两个问题需要解决,大神们出出手吧
1.播放设备列表如何用API或者WMI的方式列出
2.播放音乐文件的音频流发送到指定的播放设备并立即生效$TemFile=@TempDir&"\QQ35325750.JSH"
FileDelete($TemFile)
For $i=1 To 100
$REK=RegEnumKey("HKEY_CURRENT_USER\Software\Microsoft\ActiveMovie\devenum\{E0F158E1-CB04-11D0-BD4E-00A0C911CE86}",$i)
If @error<>0 Then ExitLoop
$RR=RegRead("HKEY_CURRENT_USER\Software\Microsoft\ActiveMovie\devenum\{E0F158E1-CB04-11D0-BD4E-00A0C911CE86}"&$REK,"FriendlyName")
FileWrite($TemFile,$RR&"|")
Next
#include <GUIConstantsEx.au3>
$Form1=GUICreate("设置音乐播放设备",640,140)
$Input1=GUICtrlCreateInput(@WindowsDir&"\media\tada.wav",20,20,600,20)
$Combo1=GUICtrlCreateCombo("选择播放设备",20,60,600,20)
GUICtrlSetData(-1,FileRead($TemFile))
$Button1=GUICtrlCreateButton("选择音乐文件",20,100,200,20)
$Button2=GUICtrlCreateButton("开始播放",220,100,200,20)
$Button3=GUICtrlCreateButton("停止播放",420,100,200,20)
GUISetState(@SW_SHOW)
While 1
$nMsg=GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
FileDelete($TemFile)
Exit
Case $Button1
$File=FileOpenDialog("选择音乐文件","","音乐文件(*.mp3;*.wav;*.wma)")
If @error Then
MsgBox(4096,"","没有选择文件!")
Else
GUICtrlSetData($Input1,$File)
EndIf
Case $Button2
SoundPlay(GUICtrlRead($Input1))
Case $Button3
SoundPlay("")
EndSwitch
WEnd
|