找回密码
 加入
搜索
查看: 3215|回复: 4

[AU3基础] 音乐暂停播放按钮示例 己解决

[复制链接]
发表于 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
 楼主| 发表于 2015-9-12 14:37:34 | 显示全部楼层
怎么我的图标点了没有反应,请帮忙
发表于 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 
 楼主| 发表于 2015-9-13 12:14:37 | 显示全部楼层
感谢mshuking 回复  我是新手au3上路中...
 楼主| 发表于 2015-9-13 12:18:42 | 显示全部楼层

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

谢谢回帖是一种美德
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-14 02:15 , Processed in 0.078139 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表