Jump to content

White Shark Audio Player


Recommended Posts

Hi all,

I have created this Audio Player with a friend.

Do you like it? :)

#cs ----------------------------------------------------------------------------

 Authors:          Lord_Blackout & Sir_Nazgul

 Script Function:  Audio Player
 Script Version:   0.9b

#ce ----------------------------------------------------------------------------

#include <Sound.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ProgressConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ###
$Form1_1 = GUICreate(".:.:. White Shark Corporation .:.:.", 762, 258, 326, 326)
GUISetBkColor(0x000000)
$Label1 = GUICtrlCreateLabel("White Shark Audio Player", 176, 16, 412, 31)
GUICtrlSetFont(-1, 20, 800, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
$Scegli = GUICtrlCreateInput("Scegli un file audio...", 48, 64, 561, 21)
$Sfoglia = GUICtrlCreateButton("Sfoglia...", 640, 64, 81, 21)
$Play = GUICtrlCreateButton("Play", 48, 104, 121, 33)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Stop = GUICtrlCreateButton("Stop", 328, 104, 113, 33)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Durata = GUICtrlCreateInput("Durata totale", 608, 104, 113, 21)
$Tempo = GUICtrlCreateInput("Tempo trascorso", 608, 136, 113, 21)
$Label2 = GUICtrlCreateLabel("Durata totale:", 520, 105, 83, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Label3 = GUICtrlCreateLabel("Tempo trascorso:", 493, 137, 110, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Pausa = GUICtrlCreateButton("Pausa", 192, 104, 113, 33)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Slider = GUICtrlCreateSlider(40, 200, 265, 33)
$Volume = GUICtrlCreateLabel("Volume", 152, 176, 50, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Label4 = GUICtrlCreateLabel("+", 288, 176, 13, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Label5 = GUICtrlCreateLabel("-", 52, 176, 9, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Mixer = GUICtrlCreateButton("Mixer", 328, 200, 113, 33, 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Sfuma = GUICtrlCreateLabel("Dissolvi", 348, 153, 52, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$CheckBox1 = GUICtrlCreateCheckbox("CheckBox1", 330, 152, 17, 17)
$Checkbox2 = GUICtrlCreateCheckbox("CheckBox", 50, 152, 17, 17)
$Label6 = GUICtrlCreateLabel("Loop", 68, 153, 35, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Progress1 = GUICtrlCreateProgress(464, 208, 281, 25)
$Label7 = GUICtrlCreateLabel("Progresso", 576, 176, 67, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Label8 = GUICtrlCreateLabel("«--´¯`--–…·´--»", 24, 24, 139, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
$Label9 = GUICtrlCreateLabel("«--`·…–--´¯`--»", 608, 24, 139, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

AutoItSetOption ( "RunErrorsFatal", 0)
$Percorso = 0
GUICtrlSetData ($Slider, 80)
While 1
    $nMsg = GUIGetMsg()
    $Slider_volume = GUICtrlRead ($Slider)
    $Casella1 = GUICtrlRead ($CheckBox1)
    $Casella2 = GUICtrlRead ($CheckBox2)
    $Durata_ms = _SoundLength ("alias_suono", 2)
    $Tempo_ms = _SoundPos ("alias_suono", 2)
    $Percentuale = $Tempo_ms / $Durata_ms * 100
    SoundSetWaveVolume ($Slider_volume)
    GUICtrlSetData ($Tempo, _SoundPos("alias_suono", 1))
    GUICtrlSetData ($Durata, _SoundLength ("alias_suono", 1))
    GUICtrlSetData ($Progress1, $Percentuale)
    
    If $Casella2 = 1 Then
        If $Tempo_ms = $Durata_ms Then
            _SoundPlay ("alias_suono")
        EndIf           
    EndIf
    
    Select
          
        Case $nMsg = $GUI_EVENT_CLOSE
            _SoundClose ("alias_suono")
            Exit
            
        Case $nMsg = $Sfoglia
            $Percorso = (FileOpenDialog("Seleziona un file audio", @ScriptDir, "(*.mp3;*.wav;*.wma)") )
            GUICtrlSetData ($Scegli, $Percorso)
            If $Casella1 = 1 Then
                While $Slider_volume > 0
                    $Slider_volume = $Slider_volume - 1
                    SoundSetWaveVolume ($Slider_volume)
                    Sleep (30)
                WEnd
            EndIf   
            _SoundClose ("alias_suono")
            _SoundOpen ($Percorso, "alias_suono")
                            
        Case $nMsg = $Play
            _SoundPlay ("alias_suono")
                                                
        Case $nMsg = $Pausa
            _SoundPause ("alias_suono")
            
        Case $nMsg = $Stop
            If $Casella1 = 1 Then
                While $Slider_volume > 0
                    $Slider_volume = $Slider_volume - 1
                    SoundSetWaveVolume ($Slider_volume)
                    Sleep (30)
                WEnd
            EndIf
            _SoundStop ("alias_suono")
                        
        Case $nMsg = $Mixer
            Run (@WindowsDir & "\system32\sndvol32.exe")
                    
    EndSelect
WEnd
Edited by LordBlackout
Link to comment
Share on other sites

Yes, I'm Italian...

Little Translation:

Dissolvi = Dissolve

Sfoglia = Browse

Progresso = Progress

Pausa = Pause

Scegli un file audio = Choose an audio file

Durata totale: Total duration

Tempo trascorso: Elapsed time

The others words are in english :)

Edited by LordBlackout
Link to comment
Share on other sites

Nice work ...

To create a playlist just put a list-view control and use _FileListToArray function (check the helpfile) to put the songs in it. To save the playlist use filewriteline or filewrite (check the helpfile for this too) ...

Hope it helps :)

P.S. - Check my media player - L|M|TER Media Player

Edited by LIMITER
Link to comment
Share on other sites

i run the script with AutoIt v3.2.10.0 but this is the error:

C:\Programmi\AutoIt3\Include\ProgressConstants.au3 (16) : ==> Variable used without being declared.: 
Global Const $PBM_SETRANGE = $WM_USER + 1 
Global Const $PBM_SETRANGE = ^ ERROR
>Exit code: 1   Time: 0.483
Link to comment
Share on other sites

i run the script with AutoIt v3.2.10.0 but this is the error:

C:\Programmi\AutoIt3\Include\ProgressConstants.au3 (16) : ==> Variable used without being declared.: 
Global Const $PBM_SETRANGE = $WM_USER + 1 
Global Const $PBM_SETRANGE = ^ ERROR
>Exit code: 1   Time: 0.483
That would be a typical error showing the script was written in one of the latest betas. You can comment out the Global constant line it is refering to on each one and should run for you :)

;Global Const $PBM_SETRANGE = $WM_USER + 1

edit - clarification

Edited by gesller
Link to comment
Share on other sites

Quick example, i just make AdlibEnable() function and now your script usage 6-8% of CPU. :)

#cs ----------------------------------------------------------------------------

Authors:           Lord_Blackout & Sir_Nazgul

Script Function:  Audio Player
Script Version:   0.9b

#ce ----------------------------------------------------------------------------

#include <Sound.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $Slider_volume, $Casella1, $Casella2, $Durata_ms, $Tempo_ms, $Percentuale

#Region ### START Koda GUI section ###
$Form1_1 = GUICreate(".:.:. White Shark Corporation .:.:.", 762, 258, 326, 326)
GUISetBkColor(0x000000)
$Label1 = GUICtrlCreateLabel("White Shark Audio Player", 176, 16, 412, 31)
GUICtrlSetFont(-1, 20, 800, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
$Scegli = GUICtrlCreateInput("Scegli un file audio...", 48, 64, 561, 21)
$Sfoglia = GUICtrlCreateButton("Sfoglia...", 640, 64, 81, 21)
$Play = GUICtrlCreateButton("Play", 48, 104, 121, 33)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Stop = GUICtrlCreateButton("Stop", 328, 104, 113, 33)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Durata = GUICtrlCreateInput("Durata totale", 608, 104, 113, 21)
$Tempo = GUICtrlCreateInput("Tempo trascorso", 608, 136, 113, 21)
$Label2 = GUICtrlCreateLabel("Durata totale:", 520, 105, 83, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Label3 = GUICtrlCreateLabel("Tempo trascorso:", 493, 137, 110, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Pausa = GUICtrlCreateButton("Pausa", 192, 104, 113, 33)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Slider = GUICtrlCreateSlider(40, 200, 265, 33)
$Volume = GUICtrlCreateLabel("Volume", 152, 176, 50, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Label4 = GUICtrlCreateLabel("+", 288, 176, 13, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Label5 = GUICtrlCreateLabel("-", 52, 176, 9, 24)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Mixer = GUICtrlCreateButton("Mixer", 328, 200, 113, 33, 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
$Sfuma = GUICtrlCreateLabel("Dissolvi", 348, 153, 52, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$CheckBox1 = GUICtrlCreateCheckbox("CheckBox1", 330, 152, 17, 17)
$Checkbox2 = GUICtrlCreateCheckbox("CheckBox", 50, 152, 17, 17)
$Label6 = GUICtrlCreateLabel("Loop", 68, 153, 35, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Progress1 = GUICtrlCreateProgress(464, 208, 281, 25)
$Label7 = GUICtrlCreateLabel("Progresso", 576, 176, 67, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x00FF00)
$Label8 = GUICtrlCreateLabel("«--??`--–…·?--»", 24, 24, 139, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
$Label9 = GUICtrlCreateLabel("«--`·…–--??`--»", 608, 24, 139, 19)
GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")
GUICtrlSetColor(-1, 0x00FF00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

AutoItSetOption ( "RunErrorsFatal", 0)
$Percorso = 0
GUICtrlSetData ($Slider, 80)

AdlibEnable("_MyAdlib", 500)

While 1
    $nMsg = GUIGetMsg()
    Select
        Case $nMsg = $GUI_EVENT_CLOSE
            _SoundClose ("alias_suono")
            Exit
        Case $nMsg = $Sfoglia
            $Percorso = (FileOpenDialog("Seleziona un file audio", @ScriptDir, "(*.mp3;*.wav;*.wma)") )
            GUICtrlSetData ($Scegli, $Percorso)
            If $Casella1 = 1 Then
                While $Slider_volume > 0
                    $Slider_volume = $Slider_volume - 1
                    SoundSetWaveVolume ($Slider_volume)
                    Sleep (30)
                WEnd
            EndIf    
            _SoundClose ("alias_suono")
            _SoundOpen ($Percorso, "alias_suono")
        Case $nMsg = $Play
            _SoundPlay ("alias_suono")
        Case $nMsg = $Pausa
            _SoundPause ("alias_suono")
        Case $nMsg = $Stop
            If $Casella1 = 1 Then
                While $Slider_volume > 0
                    $Slider_volume = $Slider_volume - 1
                    SoundSetWaveVolume ($Slider_volume)
                    Sleep (30)
                WEnd
            EndIf
            _SoundStop ("alias_suono")
        Case $nMsg = $Mixer
            Run (@WindowsDir & "\system32\sndvol32.exe")
    EndSelect
WEnd

Func _MyAdlib()
    $Slider_volume = GUICtrlRead ($Slider)
    $Casella1 = GUICtrlRead ($CheckBox1)
    $Casella2 = GUICtrlRead ($CheckBox2)
    $Durata_ms = _SoundLength ("alias_suono", 2)
    $Tempo_ms = _SoundPos ("alias_suono", 2)
    $Percentuale = $Tempo_ms / $Durata_ms * 100
    
    SoundSetWaveVolume ($Slider_volume)
    GUICtrlSetData ($Tempo, _SoundPos("alias_suono", 1))
    GUICtrlSetData ($Durata, _SoundLength ("alias_suono", 1))
    GUICtrlSetData ($Progress1, $Percentuale)
    
     If $Casella2 = 1 Then
        If $Tempo_ms = $Durata_ms Then
            _SoundPlay ("alias_suono")
        EndIf            
    EndIf
EndFunc

Why need to use SoundSetWaveVolume ($Slider_volume) regularity? Use this function only if user changed volume level. And try to avoid to use loop in loop, it`s no good idea. :(

Good luck again!

P.S.

Sorry for my english, i hope you understand me. :D

Link to comment
Share on other sites

Hmm... looks good, but progress bar not work correctly, durate time not work in general, and CPU usage 45-50%. More learn and practice!

Good luck! :)

The durate time don't work with the last autoit version and if it don't work, the progress bar can't work :(

I had to do an downgrade to use the durate time (_SoundLenght)... it's a bug of the last version of autoit?

@LIMITER: Can you write an example code for the Play-List? Thanks :D

P.S.

Yes, I'm understand perfectly, thanks!

P.S. 2

How to use SoundSetWaveVolume ($Slider_volume) only if the user change the volume?

Edited by LordBlackout
Link to comment
Share on other sites

Here's the working example :

CODE
#cs ----------------------------------------------------------------------------

Authors: Lord_Blackout & Sir_Nazgul

Script Function: Audio Player

Script Version: 0.9b

#ce ----------------------------------------------------------------------------

#include <Sound.au3>

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstants.au3>

#include <ProgressConstants.au3>

#include <SliderConstants.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <File.au3>

#include <ExtProp.au3>

Global $Slider_volume, $Casella1, $Casella2, $Durata_ms, $Tempo_ms, $Percentuale

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

#Region ### START Koda GUI section ###

$Form1_1 = GUICreate(".:.:. White Shark Corporation .:.:.", 781, 460, 122, 187)

GUISetBkColor(0x000000)

$Label1 = GUICtrlCreateLabel("White Shark Audio Player", 176, 16, 412, 31)

GUICtrlSetFont(-1, 20, 800, 0, "Lucida Console")

GUICtrlSetColor(-1, 0x00FF00)

$Scegli = GUICtrlCreateInput("Scegli un file audio...", 48, 64, 561, 21)

$Sfoglia = GUICtrlCreateButton("Sfoglia...", 640, 64, 81, 21)

$Play = GUICtrlCreateButton("Play", 48, 104, 121, 33)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Stop = GUICtrlCreateButton("Stop", 328, 104, 113, 33)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Durata = GUICtrlCreateInput("Durata totale", 608, 104, 113, 21)

$Tempo = GUICtrlCreateInput("Tempo trascorso", 608, 136, 113, 21)

$Label2 = GUICtrlCreateLabel("Durata totale:", 520, 105, 83, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Label3 = GUICtrlCreateLabel("Tempo trascorso:", 493, 137, 110, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Pausa = GUICtrlCreateButton("Pausa", 192, 104, 113, 33)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Slider = GUICtrlCreateSlider(40, 200, 265, 33)

GUICtrlSetBkColor(-1,0x000000)

$Volume = GUICtrlCreateLabel("Volume", 152, 176, 50, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Label4 = GUICtrlCreateLabel("+", 288, 176, 13, 24)

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Label5 = GUICtrlCreateLabel("-", 52, 176, 9, 24)

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Mixer = GUICtrlCreateButton("Mixer", 328, 200, 113, 33, 0)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Sfuma = GUICtrlCreateLabel("Dissolvi", 348, 153, 52, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$CheckBox1 = GUICtrlCreateCheckbox("CheckBox1", 330, 152, 17, 17)

$Checkbox2 = GUICtrlCreateCheckbox("CheckBox", 50, 152, 17, 17)

$Label6 = GUICtrlCreateLabel("Loop", 68, 153, 35, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Progress1 = GUICtrlCreateProgress(464, 208, 281, 25)

$Label7 = GUICtrlCreateLabel("Progresso", 576, 176, 67, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Label8 = GUICtrlCreateLabel("«--??`--·?--»", 24, 24, 139, 19)

GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")

GUICtrlSetColor(-1, 0x00FF00)

$Label9 = GUICtrlCreateLabel("«--`·--??`--»", 608, 24, 139, 19)

GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")

GUICtrlSetColor(-1, 0x00FF00)

$playlist = GUICtrlCreateListView("Artist|Title|Album|Path", 16, 256, 746, 182)

GUICtrlSendMsg(-1, 0x101E, 0, 200)

GUICtrlSendMsg(-1, 0x101E, 1, 200)

GUICtrlSendMsg(-1, 0x101E, 2, 200)

GUICtrlSendMsg(-1, 0x101E, 3, 140)

GUICtrlSetColor(-1, 0x00FF00)

$dirbtn = GUICtrlCreateButton("Add dir", 640, 83, 81, 21, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

AutoItSetOption ( "RunErrorsFatal", 0)

$Percorso = 0

GUICtrlSetData ($Slider, 100)

Dim $DoubleClicked = False, $playlist, $adddir

AdlibEnable("_MyAdlib", 500)

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = $GUI_EVENT_CLOSE

_SoundClose ("alias_suono")

Exit

Case $nMsg = $Sfoglia

$Percorso = (FileOpenDialog("Seleziona un file audio", @ScriptDir, "(*.mp3;*.wav;*.wma)") )

GUICtrlSetData ($Scegli, $Percorso)

If $Casella1 = 1 Then

While $Slider_volume > 0

$Slider_volume = $Slider_volume - 1

SoundSetWaveVolume ($Slider_volume)

Sleep (30)

WEnd

EndIf

_SoundClose ("alias_suono")

_SoundOpen ($Percorso, "alias_suono")

Case $nMsg = $Play

_SoundPlay ("alias_suono")

Case $nMsg = $Pausa

_SoundPause ("alias_suono")

Case $nMsg = $Stop

If $Casella1 = 1 Then

While $Slider_volume > 0

$Slider_volume = $Slider_volume - 1

SoundSetWaveVolume ($Slider_volume)

Sleep (30)

WEnd

EndIf

_SoundStop ("alias_suono")

Case $nMsg = $Mixer

Run (@WindowsDir & "\system32\sndvol32.exe")

Case $nMsg = $dirbtn

adddir()

EndSelect

If $DoubleClicked Then

DoubleClickFunc()

$DoubleClicked = False

EndIf

WEnd

Func _MyAdlib()

$Slider_volume = GUICtrlRead ($Slider)

$Casella1 = GUICtrlRead ($CheckBox1)

$Casella2 = GUICtrlRead ($CheckBox2)

$Durata_ms = _SoundLength ("alias_suono", 2)

$Tempo_ms = _SoundPos ("alias_suono", 2)

$Percentuale = $Tempo_ms / $Durata_ms * 100

SoundSetWaveVolume ($Slider_volume)

GUICtrlSetData ($Tempo, _SoundPos("alias_suono", 1))

GUICtrlSetData ($Durata, _SoundLength ("alias_suono", 1))

GUICtrlSetData ($Progress1, $Percentuale)

If $Casella2 = 1 Then

If $Tempo_ms = $Durata_ms Then

_SoundPlay ("alias_suono")

EndIf

EndIf

EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)

Local $tagNMHDR, $event, $hwndFrom, $code

$tagNMHDR = DllStructCreate("int;int;int", $lParam)

If @error Then Return 0

$code = DllStructGetData($tagNMHDR, 3)

If $wParam = $playlist And $code = -3 Then $DoubleClicked = True

Return $GUI_RUNDEFMSG

EndFunc ;==>WM_NOTIFY

Func DoubleClickFunc()

ConsoleWrite("dc" & @CRLF)

If _SoundStatus("alias_suono") = "playing" Then

_SoundStop("alias_suono")

_SoundClose("alias_suono")

EndIf

$dbclick1 = GUICtrlRead(GUICtrlRead($playlist))

ConsoleWrite($dbclick1 & @CRLF)

$dbclick2 = StringTrimRight($dbclick1, 1)

ConsoleWrite($dbclick2 & @CRLF)

$dbclick3 = StringSplit($dbclick2, "|")

ConsoleWrite($dbclick3[4] & @CRLF)

_SoundOpen($dbclick3[4],"alias_suono")

_SoundPlay("alias_suono")

EndFunc ;==>DoubleClickFunc

Func adddir()

$dir = FileSelectFolder("Select folder",@HomeDrive)

$array = _FileListToArray($dir,"*.mp3")

If IsArray($array) Then

For $i = 1 To $array[0]

TrayTip("Adding files ...","File " & $i & " of " & $array[0],1)

$path = $dir & "\" & $array[$i]

$artist1 = _GetExtProperty($path, 16) & "|"

$title1 = _GetExtProperty($path, 10) & "|"

$album1 = _GetExtProperty($path, 17) & "|"

GUICtrlCreateListViewItem($artist1 & $title1 & $album1 & $path, $playlist)

Next

Else

MsgBox(32,"Error","Please select a folder")

EndIf

EndFunc

Link to comment
Share on other sites

Thx gesller ! :)

Here's an improved version:

(changed the list-view bk color and now if you click the play button when a song is playing, it restarts it...)

CODE
#cs ----------------------------------------------------------------------------

Authors: Lord_Blackout & Sir_Nazgul & L|M|TER

Script Function: Audio Player

Script Version: 1.0

#ce ----------------------------------------------------------------------------

#include <Sound.au3>

#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstants.au3>

#include <ProgressConstants.au3>

#include <SliderConstants.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <File.au3>

#include <ExtProp.au3>

Global $Slider_volume, $Casella1, $Casella2, $Durata_ms, $Tempo_ms, $Percentuale

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

#Region ### START Koda GUI section ###

$Form1_1 = GUICreate(".:.:. White Shark Corporation .:.:.", 781, 460, 122, 187)

GUISetBkColor(0x000000)

$Label1 = GUICtrlCreateLabel("White Shark Audio Player", 176, 16, 412, 31)

GUICtrlSetFont(-1, 20, 800, 0, "Lucida Console")

GUICtrlSetColor(-1, 0x00FF00)

$Scegli = GUICtrlCreateInput("Scegli un file audio...", 48, 64, 561, 21)

$Sfoglia = GUICtrlCreateButton("Sfoglia...", 640, 64, 81, 21)

$Play = GUICtrlCreateButton("Play", 48, 104, 121, 33)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Stop = GUICtrlCreateButton("Stop", 328, 104, 113, 33)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Durata = GUICtrlCreateInput("Durata totale", 608, 104, 113, 21)

$Tempo = GUICtrlCreateInput("Tempo trascorso", 608, 136, 113, 21)

$Label2 = GUICtrlCreateLabel("Durata totale:", 520, 105, 83, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Label3 = GUICtrlCreateLabel("Tempo trascorso:", 493, 137, 110, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Pausa = GUICtrlCreateButton("Pausa", 192, 104, 113, 33)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Slider = GUICtrlCreateSlider(40, 200, 265, 33)

GUICtrlSetBkColor(-1,0x000000)

$Volume = GUICtrlCreateLabel("Volume", 152, 176, 50, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Label4 = GUICtrlCreateLabel("+", 288, 176, 13, 24)

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Label5 = GUICtrlCreateLabel("-", 52, 176, 9, 24)

GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Mixer = GUICtrlCreateButton("Mixer", 328, 200, 113, 33, 0)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

$Sfuma = GUICtrlCreateLabel("Dissolvi", 348, 153, 52, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$CheckBox1 = GUICtrlCreateCheckbox("CheckBox1", 330, 152, 17, 17)

$Checkbox2 = GUICtrlCreateCheckbox("CheckBox", 50, 152, 17, 17)

$Label6 = GUICtrlCreateLabel("Loop", 68, 153, 35, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Progress1 = GUICtrlCreateProgress(464, 208, 281, 25)

$Label7 = GUICtrlCreateLabel("Progresso", 576, 176, 67, 20)

GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

GUICtrlSetColor(-1, 0x00FF00)

$Label8 = GUICtrlCreateLabel("«--??`--·?--»", 24, 24, 139, 19)

GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")

GUICtrlSetColor(-1, 0x00FF00)

$Label9 = GUICtrlCreateLabel("«--`·--??`--»", 608, 24, 139, 19)

GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console")

GUICtrlSetColor(-1, 0x00FF00)

$playlist = GUICtrlCreateListView("Artist|Title|Album|Path", 16, 256, 746, 182)

GUICtrlSendMsg(-1, 0x101E, 0, 200)

GUICtrlSendMsg(-1, 0x101E, 1, 200)

GUICtrlSendMsg(-1, 0x101E, 2, 200)

GUICtrlSendMsg(-1, 0x101E, 3, 140)

GUICtrlSetColor(-1, 0x00FF00)

GUICtrlSetBkColor(-1, 0x000000)

$dirbtn = GUICtrlCreateButton("Add dir", 640, 83, 81, 21, 0)

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

AutoItSetOption ( "RunErrorsFatal", 0)

$Percorso = 0

GUICtrlSetData ($Slider, 100)

Dim $DoubleClicked = False, $playlist, $adddir

AdlibEnable("_MyAdlib", 500)

While 1

$nMsg = GUIGetMsg()

Select

Case $nMsg = $GUI_EVENT_CLOSE

_SoundClose ("alias_suono")

Exit

Case $nMsg = $Sfoglia

$Percorso = (FileOpenDialog("Seleziona un file audio", @ScriptDir, "(*.mp3;*.wav;*.wma)") )

GUICtrlSetData ($Scegli, $Percorso)

If $Casella1 = 1 Then

While $Slider_volume > 0

$Slider_volume = $Slider_volume - 1

SoundSetWaveVolume ($Slider_volume)

Sleep (30)

WEnd

EndIf

_SoundClose ("alias_suono")

_SoundOpen ($Percorso, "alias_suono")

Case $nMsg = $Play

If _SoundStatus("alias_suono") = "playing" Then

_SoundStop ("alias_suono")

_SoundPlay ("alias_suono")

ElseIf _SoundStatus("alias_suono") = "paused" Then

_SoundResume ("alias_suono")

Else

_SoundPlay ("alias_suono")

EndIf

Case $nMsg = $Pausa

_SoundPause ("alias_suono")

Case $nMsg = $Stop

If $Casella1 = 1 Then

While $Slider_volume > 0

$Slider_volume = $Slider_volume - 1

SoundSetWaveVolume ($Slider_volume)

Sleep (30)

WEnd

EndIf

_SoundStop ("alias_suono")

Case $nMsg = $Mixer

Run (@WindowsDir & "\system32\sndvol32.exe")

Case $nMsg = $dirbtn

adddir()

EndSelect

If $DoubleClicked Then

DoubleClickFunc()

$DoubleClicked = False

EndIf

WEnd

Func _MyAdlib()

$Slider_volume = GUICtrlRead ($Slider)

$Casella1 = GUICtrlRead ($CheckBox1)

$Casella2 = GUICtrlRead ($CheckBox2)

$Durata_ms = _SoundLength ("alias_suono", 2)

$Tempo_ms = _SoundPos ("alias_suono", 2)

$Percentuale = $Tempo_ms / $Durata_ms * 100

SoundSetWaveVolume ($Slider_volume)

GUICtrlSetData ($Tempo, _SoundPos("alias_suono", 1))

GUICtrlSetData ($Durata, _SoundLength ("alias_suono", 1))

GUICtrlSetData ($Progress1, $Percentuale)

If $Casella2 = 1 Then

If $Tempo_ms = $Durata_ms Then

_SoundPlay ("alias_suono")

EndIf

EndIf

EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)

Local $tagNMHDR, $event, $hwndFrom, $code

$tagNMHDR = DllStructCreate("int;int;int", $lParam)

If @error Then Return 0

$code = DllStructGetData($tagNMHDR, 3)

If $wParam = $playlist And $code = -3 Then $DoubleClicked = True

Return $GUI_RUNDEFMSG

EndFunc ;==>WM_NOTIFY

Func DoubleClickFunc()

If _SoundStatus("alias_suono") = "playing" Then

_SoundStop("alias_suono")

_SoundClose("alias_suono")

EndIf

$dbclick1 = GUICtrlRead(GUICtrlRead($playlist))

$dbclick2 = StringTrimRight($dbclick1, 1)

$dbclick3 = StringSplit($dbclick2, "|")

_SoundOpen($dbclick3[4],"alias_suono")

_SoundPlay("alias_suono")

EndFunc ;==>DoubleClickFunc

Func adddir()

$dir = FileSelectFolder("Select folder",@HomeDrive)

$array = _FileListToArray($dir,"*.mp3")

If IsArray($array) Then

For $i = 1 To $array[0]

TrayTip("Adding files ...","File " & $i & " of " & $array[0],1)

$path = $dir & "\" & $array[$i]

$artist1 = _GetExtProperty($path, 16) & "|"

$title1 = _GetExtProperty($path, 10) & "|"

$album1 = _GetExtProperty($path, 17) & "|"

GUICtrlCreateListViewItem($artist1 & $title1 & $album1 & $path, $playlist)

Next

Else

MsgBox(32,"Error","Please select a folder")

EndIf

EndFunc

Edited by LIMITER
Link to comment
Share on other sites

Oops ... The #include's were screwed up ...

just add these :

#include <Sound.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ExtProp.au3>
Edited by LIMITER
Link to comment
Share on other sites

Ups ... The #include's where screwed up ...

just add these :

#include <Sound.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstants.au3>
#include <ProgressConstants.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ExtProp.au3>
Oh good, now all work good!

Thanks!

Only one thing: if I try to add a folder with subfolders, it give an error (Please select a folder)...

Link to comment
Share on other sites

You should check out AMP 3 its my media player

I would be glad to help you with yours if there are any features in mine that you like and want help putting into yours just let me know.

Also AMP 2 is a good script to take a look at as far as learning about some of the things I learned while in my first few months developing amp. There are lots of good media players on here!

[center][/center]

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...