Что нового

[Файловая система] простой аудио плеер

johnmarshall

Осваивающий
Сообщения
192
Репутация
35
AutoIt: 3.3.8.1
Версия: 1.0
Лицензия:
Категория: Файловая система, Медиа

Описание:
мне нужен был небольшой аудио плеер.
вот нашел на просторах интернета, может кому-то пригодится.
тут не нашел. добавляю.

Код/Пример:
Код:
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>

Global $Fpath = FileOpenDialog("Select Audio file",@WorkingDir,"Sound Files(*.mp3;*.wav)|All Files(*.*)")
Global $Playing = False
Global $SoundHwnd
If Not @error Then $SoundHwnd = _SoundOpen($Fpath)
If Not @error Then
    $MPlayer = GUICreate("Music Player", 243,40, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME), BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE))
    GUISetBkColor(0x000000)
    $BACK = GUICtrlCreateButton("<<", 44, 8, 35, 25, BitOR($BS_FLAT,$WS_BORDER))
    $STOP = GUICtrlCreateButton("[A?]", 84, 8, 35, 25, BitOR($BS_FLAT,$WS_BORDER))
    GUICtrlSetFont(-1, 8, 400, 4, "Arial")
    $PLAYORPAUSE = GUICtrlCreateButton("l>", 124, 8, 35, 25, BitOR($BS_FLAT,$WS_BORDER))
    GUICtrlSetFont(-1, 8, 400, 0, "Arial")
    GUICtrlSetTip(-1, "")
    $FORWARD = GUICtrlCreateButton(">>", 164, 8, 35, 25, BitOR($BS_FLAT,$WS_BORDER))
    GUISetState(@SW_SHOW)
    _SoundPlay($SoundHwnd)
    $Playing = True
    GUICtrlSetData($PLAYORPAUSE,"||")
While 1
    Switch GUIGetMsg()
        Case -3
            _SoundClose($SoundHwnd)
            Exit
        Case $PLAYORPAUSE
            If Not $Playing Then
                _SoundPlay($SoundHwnd)
                GUICtrlSetData($PLAYORPAUSE,"||")
                $Playing = True
            ElseIf $Playing Then
                _SoundPause($SoundHwnd)
                GUICtrlSetData($PLAYORPAUSE,"l>")
                $Playing = False
            EndIf
        Case $BACK
            If $Playing Then
                $HMS = StringSplit(_SoundPos($SoundHwnd,1),":")
                If IsArray($HMS) Then
                    _SoundPause($SoundHwnd)
                    _SoundSeek($SoundHwnd,$HMS[1],$HMS[2],$HMS[3]-10)
                    _SoundPlay($SoundHwnd)
                EndIf
            EndIf
        Case $FORWARD
            If $Playing Then
                $HMS = StringSplit(_SoundPos($SoundHwnd,1),":")
                If IsArray($HMS) Then
                    _SoundPause($SoundHwnd)
                    _SoundSeek($SoundHwnd,$HMS[1],$HMS[2],$HMS[3]+10)
                    _SoundPlay($SoundHwnd)
                EndIf
            EndIf
        Case $STOP
            GUICtrlSetData($PLAYORPAUSE,"l>")
            _SoundStop($SoundHwnd)
EndSwitch
        WinSetTitle(WinGetHandle($MPlayer),"Music Player",_SoundPos($SoundHwnd,1) & " / " & _SoundLength($SoundHwnd,1))
        If _SoundPos($SoundHwnd,1) >= _SoundLength($SoundHwnd,1) Then
            Sleep(500)
            _SoundPlay($SoundHwnd)
        EndIf
WEnd
EndIf

Снимок:


История версий:
1.0

Источник: autoit-script.ru
Автор(ы): доставляет damien2008
 
Верх