zpmc123 发表于 2015-9-12 14:36:10

音乐暂停播放按钮示例 己解决

本帖最后由 zpmc123 于 2018-5-22 11:30 编辑

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("音乐暂停按钮示例", 623, 442, 192, 124)
FileInstall("Sound\C.jpg", @TempDir & "\")
$Pic1 = GUICtrlCreatePic( @TempDir & "\c.jpg", 8, 8, 604, 100)
FileDelete(@TempDir & "\c.jpg")
_soundplay(@ScriptDir & "\sound\AM SoftIns.mp3" , 0)   ;AM SoftIns.mp3为音乐名称
$pu = GUICtrlCreateIcon(@ScriptDir & "\sound\播放.ico", 0, 20, 343, 32, 32);此处按钮点击后显示下面暂停ICO
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "单击背景音乐暂停")
GUICtrlSetOnEvent($pu, "sound_pause")
$pl = GUICtrlCreateIcon(@ScriptDir & "\sound\暂停.ico", 0, 20, 343, 32, 32);此处按钮点击后显示下面播放ICO
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "单击背景音乐继续")
GUICtrlSetOnEvent($pl, "sound_play")
GUICtrlSetState($pl, $gui_hide)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func sound_pause()
        GUICtrlSetState($pu, $gui_hide)
        GUICtrlSetState($pl, $gui_show)
        _soundpause(@ScriptDir & "\sound\AM SoftIns.mp3" )
EndFunc

Func sound_play()
        GUICtrlSetState($pl, $gui_hide)
        GUICtrlSetState($pu, $gui_show)
        _soundplay(@ScriptDir & "\sound\AM SoftIns.mp3" , 0)
EndFunc




感谢mshuking的帮助#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("音乐暂停按钮示例", 623, 442, 192, 124)
FileInstall("Sound\C.jpg", @TempDir & "\")
$Pic1 = GUICtrlCreatePic( @TempDir & "\c.jpg", 8, 8, 604, 100)
FileDelete(@TempDir & "\c.jpg")
_soundplay(@ScriptDir & "\sound\AM SoftIns.mp3" , 0)   ;AM SoftIns.mp3为音乐名称
$pu = GUICtrlCreateIcon(@ScriptDir & "\sound\播放.ico", 0, 20, 343, 32, 32);此处按钮点击后显示下面暂停ICO
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "单击背景音乐暂停")
GUICtrlSetOnEvent($pu, "sound_pause")
$pl = GUICtrlCreateIcon(@ScriptDir & "\sound\暂停.ico", 0, 20, 343, 32, 32);此处按钮点击后显示下面播放ICO
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "单击背景音乐继续")
GUICtrlSetOnEvent($pl, "sound_play")
GUICtrlSetState($pl, $gui_hide)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
      Case $pu
                sound_pause()
      Case $pl
                sound_play()
      EndSwitch
WEnd

Func sound_pause()
      GUICtrlSetState($pu, $gui_hide)
      GUICtrlSetState($pl, $gui_show)
      _soundpause(@ScriptDir & "\sound\AM SoftIns.mp3" )
EndFunc

Func sound_play()
      GUICtrlSetState($pl, $gui_hide)
      GUICtrlSetState($pu, $gui_show)
      _soundplay(@ScriptDir & "\sound\AM SoftIns.mp3" , 0)
EndFunc

zpmc123 发表于 2015-9-12 14:37:34

怎么我的图标点了没有反应,请帮忙

mshuking 发表于 2015-9-12 18:51:36

本帖最后由 mshuking 于 2015-9-13 12:00 编辑

你按钮 都没加进去点怎么工作#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("音乐暂停按钮示例", 623, 442, 192, 124)
FileInstall("Sound\C.jpg", @TempDir & "\")
$Pic1 = GUICtrlCreatePic( @TempDir & "\c.jpg", 8, 8, 604, 100)
FileDelete(@TempDir & "\c.jpg")
_soundplay(@ScriptDir & "\sound\AM SoftIns.mp3" , 0)   ;AM SoftIns.mp3为音乐名称
$pu = GUICtrlCreateIcon(@ScriptDir & "\sound\播放.ico", 0, 20, 343, 32, 32);此处按钮点击后显示下面暂停ICO
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "单击背景音乐暂停")
GUICtrlSetOnEvent($pu, "sound_pause")
$pl = GUICtrlCreateIcon(@ScriptDir & "\sound\暂停.ico", 0, 20, 343, 32, 32);此处按钮点击后显示下面播放ICO
GUICtrlSetCursor(-1, 0)
GUICtrlSetTip(-1, "单击背景音乐继续")
GUICtrlSetOnEvent($pl, "sound_play")
GUICtrlSetState($pl, $gui_hide)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        Case $pu
                sound_pause()
        Case $pl
                sound_play()
      EndSwitch
WEnd

Func sound_pause()
      GUICtrlSetState($pu, $gui_hide)
      GUICtrlSetState($pl, $gui_show)
      _soundpause(@ScriptDir & "\sound\AM SoftIns.mp3" )
EndFunc

Func sound_play()
      GUICtrlSetState($pl, $gui_hide)
      GUICtrlSetState($pu, $gui_show)
      _soundplay(@ScriptDir & "\sound\AM SoftIns.mp3" , 0)
EndFunc

zpmc123 发表于 2015-9-13 12:14:37

感谢mshuking 回复我是新手au3上路中...

zpmc123 发表于 2015-9-13 12:18:42

RE: 音乐暂停播放按钮示例己解决

谢谢回帖是一种美德
页: [1]
查看完整版本: 音乐暂停播放按钮示例 己解决