lele9013 发表于 2008-12-31 11:23:49

现在用au3写的mp3播放器 能否 用进度条快进?

。。。

我在论坛 和官方论坛 搜索 均发现

用au3写的mp3播放器 都不能用进度条快进

请问能解决吗?

[ 本帖最后由 lele9013 于 2009-1-28 23:34 编辑 ]

lele9013 发表于 2009-1-10 12:10:02

... - -继续求教

yuheduo 发表于 2009-1-12 11:24:25

不好用,太耗cpu了。我以前试过的

gogo023 发表于 2009-1-12 23:53:47

我记得有一个周星驰的崇拜者写过这样的MP3播放器。

pusofalse 发表于 2009-1-13 02:09:47

试写了一个,看下是否是这么回事。
注册消息,拦截滑动条消息。 把_play函数中的Canon.mp3换成你的歌曲。
#include <Date.au3>
#include <sound.au3>

Global const $wm_Hscroll = 0x0114

Opt("GuiOnEventMode", 1)
Global $Flag = 0
Local $OldProgress

$hGui = GuiCreate('player', 400, 110)
GuiSetOnEvent(-3, "_exit", $hGui)

$slider = GuiCtrlCreateSlider(20, 20, 360, 20)
GuiCtrlSetOnEvent(-1, "_slider")

$btnPlay = GuiCtrlCreateButton("Play", 60, 60, 60, 30)
GuiCtrlSetOnEvent(-1, "_play")
$btnStop = GuiCtrlCreateButton("Stop", 280, 60, 60, 30)
GuiCtrlSetOnEvent(-1, "_stop")

GuiSetState()
GuiRegisterMsg($wm_Hscroll, "_wmHscroll")


While 1
        If $Flag then
                sleep(100)
                If _soundPos("myMusic", 2) / _soundLength("myMusic", 2) * 100 = $OldProgress then ContinueLoop
                GuiCtrlSetData($slider, _soundPos("myMusic", 2) / _soundLength("myMusic", 2) * 100)
                $OldProgress = _soundPos("myMusic", 2) / _soundLength("myMusic", 2) * 100
                If _soundPos("myMusic") = _soundLength("myMusic") then
                                _play()
                                GuiCtrlSetData($slider, 0)
                EndIf
                ContinueLoop
        EndIf
        Sleep(2000)
WEnd        ;==>main

Func _exit()
        exit(0)
EndFunc        ;==>_exit()

Func _wmHscroll($hWnd, $message, $wParam, $sParam)
        #forceref $hWnd, $message, $wParam, $sParam
        Local $hour, $min, $sec
        $curPos = GuiCtrlRead($slider) / 100 * _soundLength("mymusic", 2)
        _ticksToTime($curPos, $hour, $min, $sec)
        $Prompt = stringFormat("%i:%02i:%02i", $hour, $min, $sec)
        toolTip($Prompt)
        _soundSeek("myMusic", $hour, $min, $sec)
EndFunc        ;==>_wmHscroll()

Func _slider()
        toolTip('')
        If $Flag then _soundPlay("myMusic")
EndFunc        ;==>_slider()

Func _play()
        If not $Flag then
                If _soundPos("myMusic") = _soundLength("myMusic") then
                        _soundClose("myMusic")
                        _soundOpen("Canon.Mp3", "myMusic")
                EndIf
                _soundPlay("myMusic")
                GuiCtrlSetData($btnPlay, "Pause")
        Else
                _soundPause("myMusic")
                GuiCtrlSetData($btnPlay, "Play")
        EndIf
        $Flag = not $Flag
EndFunc        ;==>_stop()

Func _stop()
        _soundStop("myMusic")
        GuiCtrlSetData($btnPlay, "Play")
        GuiCtrlSetData($slider, 0)
        $Flag = 0
EndFunc        ;==>_stop()

lele9013 发表于 2009-1-28 23:34:19

非常感谢楼上的代码。。

ceoguang 发表于 2009-2-12 20:19:13

回5#,最新版本提示line51出错!
3213版本正常.

pusofalse 发表于 2009-2-12 21:29:52

回复 7# ceoguang 的帖子

没用过最新版本~可能是新版本中没有_soundseek函数的缘故。 具体提示什么错误?

ceoguang 发表于 2009-2-12 23:19:45

具体提示忘了,不过,以尔等能力,相信为wmp.au3加个快进功能应该不难
附UDF

#cs
_wmpcreate($show, $left, $top, $width = 100, $height = 100)
$show:   1 = shows controls
      2 = hides controls

Return: The object for the control
#ce
Func _wmpcreate($show, $left, $top, $width = 100, $height = 100)
$oWMP = ObjCreate("WMPlayer.OCX")
If $oWMP = 0 Then Return 0
$oWMP.settings.autoStart = "False"
If $show = 1 Then
    GUICtrlCreateObj($oWMP, $left, $top, $width, $height)
EndIf
Return $oWMP
EndFunc
#cs
_wmploadmedia( $object, $URL, $autostart = 1 )
$object:    Object returned from the _wmpcreate()
$URL:      Path or URL of the media
$autostart:    1 = yes
            0 = no

Return: None
#ce
Func _wmploadmedia( $object, $URL, $autostart = 1 )
    $object.URL = $URL
    If $autostart = 1 And $object.controls.isAvailable("play") Then $object.controls.play()
EndFunc
#cs
_wmpsetvalue( $object, $setting, $para=1 )
$object:    Object returned from the _wmpcreate()
$setting:    "play"
            "stop"
            "pause"
            "invisible" (Hides all)
            "control"    (Shows controls)
            "nocontrol"    (Hides controls)
            "fullscreen"
            "step"      (frames to step before freezing)
            "fastforward"
            "fastreverse"
            "volume"    (0 To 100)
            "rate"      (-10 To 10)
            "playcount"

Return: None
#ce
Func _wmpsetvalue( $object, $setting, $para=1 )
      Select
                Case $setting = "play"
            If $object.controls.isAvailable("play") Then $object.controls.play()
      Case $setting = "stop"
            If $object.controls.isAvailable("stop") Then $object.controls.stop()
      Case $setting = "pause"
            If $object.controls.isAvailable("pause") Then $object.controls.pause()
      Case $setting = "invisible"
            $object.uiMode = "invisible"
      Case $setting = "controls"
            $object.uiMode = "mini"
      Case $setting = "nocontrols"
            $object.uiMode = "none"
      Case $setting = "fullscreen"
            $object.fullscreen = "true"
      Case $setting = "step"
            If $object.controls.isAvailable("step") Then $object.controls.step($para)
      Case $setting = "fastForward"
            If $object.controls.isAvailable("fastForward") Then $object.controls.fastForward()
      Case $setting = "fastReverse"
            If $object.controls.isAvailable("fastReverse") Then $object.controls.fastReverse()
      Case $setting = "volume"
            $object.settings.volume = $para
      Case $setting = "rate"
            $object.settings.rate = $para
      Case $setting = "playcount"
            $object.settings.playCount = $para
    EndSelect
EndFunc

xiaopuff 发表于 2009-7-14 00:35:45

:face (37):
页: [1]
查看完整版本: 现在用au3写的mp3播放器 能否 用进度条快进?