Jump to content

Recommended Posts

Posted

your player is very good...i just want to asked something:

when you play a song the player stops after finishing

can you make it that the player plays the next song in the list automaticly?

mb

  • 5 months later...
Posted

I fixed the code so it doesnt show that error its the latest version by ludocus too :)

#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 <GuiListBox.au3>
#include <File.au3>

$prevsong = ''
$playlistFile = @Tempdir&'\little mp playlist.pl'
global $pl1 = 0
global $media = 0
Global $Slider_volume, $Casella1, $Casella2, $Durata_ms, $Tempo_ms, $lool, $song
$Form1_1 = GUICreate("Little Music Player", 406, 256, 193, 125)
GUISetFont(10, 400, 0, "Verdana")
$Scegli = GUICtrlCreateInput("File Audio...", 16, 16, 281, 20)
$Sfoglia = GUICtrlCreateButton("Parcourir...", 312, 14, 81, 25, 0)
$play = GUICtrlCreateButton("Play", 312, 48, 81, 25, 0)
$Pausa = GUICtrlCreateButton("Pause", 312, 80, 81, 25, 0)
$Stop = GUICtrlCreateButton("Stop", 312, 112, 81, 25, 0)
$Tempo2 = GUICtrlCreateLabel("Temp Passé :", 16, 48, 73, 16)
$Tempo = GUICtrlCreateInput("", 96, 47, 113, 20)
$Label1 = GUICtrlCreateLabel("Volume :   -                                                    +", 16, 88, 232, 16)
$Slider = GUICtrlCreateSlider(64, 112, 185, 25)
$Mixer = GUICtrlCreateButton("Mixer", 312, 144, 81, 25, 0)
$Label2 = GUICtrlCreateLabel("Little Media Player By H4CK-H-RAF", 80, 182, 186, 16)
$Progress1 = GUICtrlCreateProgress(24, 144, 265, 17)
$List = GUICtrlCreateList("", 16, 175, 281, 78)
_LoadFileToList($playlistFile, $List)
$menu = GUICtrlCreateContextMenu($List)
$add = GUICtrlCreateMenuItem('Add', $menu)
$del = GUICtrlCreateMenuItem('Del', $menu)
GUISetState(@SW_SHOW)
$Percorso = 0
GUICtrlSetData ($Slider, 80)
AdlibEnable("_MyAdlib", 500)
While 1
$pos = _SoundPos($Media, 2)
$length = _SoundLength($Media, 2)
GUICtrlSetData($Progress1, ($pos/$length)*100)
$nMsg = GUIGetMsg()
Select
Case $nMsg = $GUI_EVENT_CLOSE
_SoundClose ($Media)
Exit
Case $nMsg = $Sfoglia
_SoundStop($Media)
$Path=FileSelectFolder("Choose a directory", '')
If $Path <> '' then _AddDir($Path)
Case $nMsg = $Play
$listread = GUICtrlRead($list)
If $listread<>'' then
    if $listread<>$prevsong then
    if _SoundStatus($Media)='playing' then _SoundStop($Media)
    $songdir = StringSplit($listread, '[', 1)
    $2 = StringSplit($listread, ' - ',1)
    $3 = StringSplit($2[2], ' :', 1)
    $Media = _SoundOpen($songdir[2])
    _SoundPlay($Media)
    Else
    _SoundPlay($Media)
    EndIf
    $prevsong=$listread
EndIf

SoundSetWaveVolume(100)
GUICtrlSetData($Scegli, $3[1]&' - '&$2[1])
_GUICreateSmallPlay($3[1], $2[1], 'Little MP' )
Case $nMsg = $Pausa
_SoundPause ($Media)
Case $nMsg = $Stop
If $Casella1 = 1 Then
While $Slider_volume > 0
$Slider_volume = $Slider_volume - 1
SoundSetWaveVolume ($Slider_volume)
Sleep (30)
WEnd
EndIf
_SoundStop ($Media)
Case $nMsg = $Mixer
SoundPlay("C:\Windows\Media\tada.wav")
case $nMsg = $add
    _AddFile()
   
Case $nMsg = $del
    $i = _GUICtrlListBox_GetCurSel($List)
    _GUICtrlListBox_DeleteString($List, $i)
    _FileWriteToLine($playlistFile, $i+1, '', 1)
   
   
   
EndSelect
WEnd
Func _AddFile()
    $file = FileOpenDialog('Please choose a file to add', '', 'audio files (*.mp3; *.wma; *.wav)')
    if $file = '' then Return -1
    $artist1 = _GetExtProperty($file, 16)
    $title1 = _GetExtProperty($file, 10)
    $time1 = _GetExtProperty($file, 21)
    GUICtrlSetData($list, $artist1 &" - " &  $title1 & " :" &  $time1 & "                                                       [" & $file)
    _FileWriteToLine($playlistFile, _FileCountLines($playlistFile)+1, $artist1 &" - " &  $title1 & " :" &  $time1 & "                                                       [" & $file, 1)
EndFunc

Func _LoadFileToList($playlistFile, $List)
    $o = FileOpen($playlistFile, 0)
    While 1
        $line = FileReadLine($o)
        if $line = '' then exitloop
        GUICtrlSetData($List, $line )
    WEnd
    FileClose($o)
EndFunc



Func _GUICreateSmallPlay($gTitle, $gArtist, $sProgTitle='', $sWidth=100, $sHeight=100, $sLeft = '', $sTop = '', $sStyle='', $sExStyle='', $sBkcolor=0x4DCBE6, $sWait=500)
if $sProgTitle = '' then $sProgTitle = "White'nBlue"
if $sExStyle = '' then $sExStyle = BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)
if $sStyle = '' then $sStyle = $WS_POPUPWINDOW
if $sLeft = '' then $sLeft = @DesktopWidth-100
if $sTop = '' then $sTop = @DesktopHeight-100
$smallPlayGui = GUICreate($gTitle, $sWidth, 0, $sLeft, $sTop, $sStyle, $sExStyle)
if @error then $error += @error
GUISetBkColor($sBkColor)
if @error then $error += @error
WinSetTrans($smallPlayGui, '', 200)
GUICtrlCreateLabel($gTitle&@CRLF&@CRLF&$gArtist, 0, 30, 100, 70)
GUICtrlSetFont(-1, 10, 400, 0, "Verdena")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateLabel($sProgTitle, 0, 0, 100, 10)
GUICtrlSetFont(-1, 8, 800, 0, "Verdena")
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState()
For $i = 1 to $sHeight
sleep(1)
WinMove($smallPlayGui, '', $sLeft, $sTop, $sWidth, $i)
Next
sleep($sWait)
For $i = $sHeight to 1 step -1
sleep(1)
WinMove($smallPlayGui, '', $sLeft, $sTop, $sWidth, $i)
Next
GUIDelete($smallPlayGui)
return SetError($error)
EndFunc

Func _AddDir($sPath)
$array = _FileListToArray($sPath, "*.mp3")
If IsArray($array) Then
if FileExists($playlistFile) then FileDelete($playlistFile)
_FileCreate($playlistFile)
GUICtrlSetData($List, '')
For $i = 1 To $array[0]
TrayTip("Adding files ...","File " & $i & " of " & $array[0],1)
$path = $sPath & "\" & $array[$i]
$artist1 = _GetExtProperty($path, 16)
$title1 = _GetExtProperty($path, 10)
$time1 = _GetExtProperty($path, 21)
GUICtrlSetData($list, $artist1 &" - " &  $title1 & " :" &  $time1 & "                                                       [" & $path)
_FileWriteToLine($playlistFile, $i, $artist1 &" - " &  $title1 & " :" &  $time1 & "                                                     [" & $path, 1)
Next
Else
MsgBox(32,'Little Media Player',"Error.. Please select a folder")
EndIf
EndFunc

Func _MyAdlib()
$Slider_volume = GUICtrlRead ($Slider)
GUICtrlSetData ($Tempo, _SoundPos($Media, 1))
$Durata_ms = _SoundLength ($Media, 2)
$Tempo_ms = _SoundPos ($Media, 2)
$Percentuale = $Tempo_ms / $Durata_ms * 100
GUICtrlSetData ($Progress1, $lool)
SoundSetWaveVolume ($Slider_volume)
If $Casella2 = 1 Then
If $Tempo_ms = $Durata_ms Then
_SoundPlay ($Media)
EndIf          
EndIf
EndFunc

;===============================================================================
; Function Name:    GetExtProperty($sPath,$iProp)
; Description:    Returns an extended property of a given file.
; Parameter(s):  $sPath - The path to the file you are attempting to retrieve an extended property from.
;                  $iProp - The numerical value for the property you want returned. If $iProp is is set
;                      to -1 then all properties will be returned in a 1 dimensional array in their corresponding order.
;                    The properties are as follows:
;                    Name = 0
;                    Size = 1
;                    Type = 2
;                    DateModified = 3
;                    DateCreated = 4
;                    DateAccessed = 5
;                    Attributes = 6
;                    Status = 7
;                    Owner = 8
;                    Author = 9
;                    Title = 10
;                    Subject = 11
;                    Category = 12
;                    Pages = 13
;                    Comments = 14
;                    Copyright = 15
;                    Artist = 16
;                    AlbumTitle = 17
;                    Year = 18
;                    TrackNumber = 19
;                    Genre = 20
;                    Duration = 21
;                    BitRate = 22
;                    Protected = 23
;                    CameraModel = 24
;                    DatePictureTaken = 25
;                    Dimensions = 26
;                    Width = 27
;                    Height = 28
;                    Company = 30
;                    Description = 31
;                    FileVersion = 32
;                    ProductName = 33
;                    ProductVersion = 34
; Requirement(s):   File specified in $spath must exist.
; Return Value(s):  On Success - The extended file property, or if $iProp = -1 then an array with all properties
;                  On Failure - 0, @Error - 1 (If file does not exist)
; Author(s):        Simucal (Simucal@gmail.com)
; Note(s):
;
;===============================================================================
Func _GetExtProperty($sPath, $iProp)
    Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
    $iExist = FileExists($sPath)
    If $iExist = 0 Then
        SetError(1)
        Return "No file loaded"
    Else
        $sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
        $sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
        $oShellApp = ObjCreate ("shell.application")
        $oDir = $oShellApp.NameSpace ($sDir)
        $oFile = $oDir.Parsename ($sFile)
        If $iProp = -1 Then
            Local $aProperty[35]
            For $i = 0 To 34
                $aProperty[$i] = $oDir.GetDetailsOf ($oFile, $i)
            Next
            Return $aProperty
        Else
            $sProperty = $oDir.GetDetailsOf ($oFile, $iProp)
            If $sProperty = "" Then
                Return "None"
            Else
                Return $sProperty
            EndIf
        EndIf
    EndIf
EndFunc  ;==>_GetExtProperty
  • 5 years later...
Posted

Cool music player and functions...! But in List of musics, I want only show the title, not artists and genre. Just title...! Which one should I remove ?

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
  • Recently Browsing   0 members

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