Mediaplayer mit Playlist Funktion

  • Huhu,
    Ich möchte euch meinen Mediaplayer vorstellen. Auch wenn es verscheihnlich inzwischen schon viele gibt würde ich nur zugern wissen was ihr von meinem Script halltet :)

    Es ist fasst zu 100% von mir geschrieben. Ich möchte mich nur bei Autobert und Andy bedanken da sie mir bei 2 kleinen Problemen geholfen haben :)
    https://autoit.de/index.php?page…2680#post182680
    https://autoit.de/index.php?page…5019#post185019

    Der Mediaplayer kann:
    -Playlists abspielen
    -Besitzt einen Progress welcher die abgelaufene Zeit eines Liedes wiedergibt
    -Besitzt Play/Stop/Pause/Weiter Buttons
    -Die Script Lautstärke ist Einstellbar.
    Wie Funktioniert er?
    Ihr erstellt im Music Ordner, Ordner mit dem Interpreten eurer Wahl. also z.B. Greenday und kopiert dort die Lieder die ihr von Green Day besitzt Rein. :)
    Erstellen einer Playlist:
    Ihr klickt im Player oben auf Playlists und dann dort auf Add Playlist. Ihr gebt dort einen Namen ein und fertig.
    Danach wählt ihr einen Interpreten und einen Song aus und klickt auf Add Song 2 Playlist. Zum starten einfach auf Start Playlist ;)

    Bugs:
    -Wenn Playlist abgespielt wird kann das Script nurnoch per Autoit-Exit(also Rechtsunten in der Taskleiste) beendet werden. Und man kann die Lautstärke nichtmehr ändern sowie der Prozess und die Buttons funktionieren nichtmehr.
    -Nur der letzte Song einer Playlist kann gelöscht werden.

    Was wird noch kommen:
    -Prozess komplett funktionsfähig und eine Funktion hinzufügen um das Lied vorzuspulen.
    -Gui verschönern
    -Bugs fixen
    -Code überarbeiten

    Source:

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <ComboConstants.au3>
    #include <File.au3>
    #include <Array.au3>
    #include <Sound.au3>
    #include <GuiEdit.au3>
    SoundSetWaveVolume(100)
    Global $Pause_janein=1,$Sound_opened="abc",$Loadbarzahl=-1,$Sond_lengh2=0,$Go_janein=0,$Combo_Playlist_Songs_add,$Combo_Playlist_Interprets_add
    Opt("GUIOnEventMode", 1)
    $Mp3MainPath = "Music\"
    $PlaylistsMainPath = "Playlists\"
    $GUI=GUICreate("Media Player V 1.0 Beta", 500, 101)
    GUICtrlCreateTab(1,1,499)
    $Item_Player=GUICtrlCreateTabItem("Player")
    GUICtrlCreateButton("Play", 105, 55, 89, 44)
    GUICtrlSetOnEvent(-1,"_play")
    $Pause=GUICtrlCreateButton("Pause", 205, 55, 89, 44)
    GUICtrlSetOnEvent(-1,"_pause")
    GUICtrlCreateButton("Stop", 305, 55, 89, 44)
    GUICtrlSetOnEvent(-1,"_Stop")
    $Loadbar=GUICtrlCreateProgress(5,81,89,19)
    GUICtrlCreateButton("Exit", 5, 57, 89, 20)
    GUICtrlSetOnEvent(-1,"_exit")
    GUICtrlCreateButton("Volume Level(%)", 405, 57, 89, 20)
    GUICtrlSetOnEvent(-1,"_setsound")
    $Soundvol=GUICtrlCreateInput("100",405,80,89,20)
    $Combo_Interpret = GUICtrlCreateCombo("Interpret", 1, 31, 199, 999, $CBS_DROPDOWNLIST)
    GUICtrlSetOnEvent(-1, "Songs")
    $Combo_Song = GUICtrlCreateCombo("Song", 200, 31, 299, 319)
    GUISetOnEvent(-3,"_exit")
    $Item_Playlist=GUICtrlCreateTabItem("Playlist")
    $Combo_Playlists=GUICtrlCreateCombo("Playlists",1,31,199,999,$CBS_DROPDOWNLIST)
    GUICtrlCreateButton("Delete Playlist",200,31,99,20)
    GUICtrlSetOnEvent(-1,"_Delete_Playlist")
    GUICtrlCreateButton("Start Playlist",300,31,99,20)
    GUICtrlSetOnEvent(-1,"_Start_Playlist")
    GUICtrlCreateButton("Add Playlist",400,31,99,20)
    GUICtrlSetOnEvent(-1,"_Add_Playlist")
    GUICtrlCreateButton("Add Song 2 Playlist",400,52,99,20)
    GUICtrlSetOnEvent(-1,"_Add_Song2_Playlist")
    $Combo_Playlist_Interprets_add=GUICtrlCreateCombo("Playlists_Interpets_add",1,52,199,999,$CBS_DROPDOWNLIST)
    GUICtrlSetOnEvent(-1,"Songs2")
    $Combo_Playlist_Songs_add=GUICtrlCreateCombo("Playlists_Songs_add",200,52,199,999,$CBS_DROPDOWNLIST)
    $Combo_Playlist_Interpret_and_Songs_exist=GUICtrlCreateCombo("Playlists Interprets&Songs",1,73,400,999,$CBS_DROPDOWNLIST)
    GUICtrlSetOnEvent(-1,"_CreatePlaylistssongsandInterprets")
    GUICtrlCreateButton("Delete Song from List",400,72,99,20)
    GUICtrlSetOnEvent(-1,"_Delete_Song_from_Playlist")
    _CreateInterpret()
    Songs()
    Songs2()
    _CreatePlaylists()
    _CreatePlaylistssongsandInterprets()
    GUISetState()
    Func Songs2()
    $Interpret_Read = GUICtrlRead($Combo_Playlist_Interprets_add)
    $Songs = _FileListToArray($Mp3MainPath & "\" & $Interpret_Read, "*", 1)
    If IsArray($Songs) Then
    GUICtrlSetData($Combo_Playlist_Songs_add, "", "")
    For $A_Anz1 = 1 To UBound($Songs) - 1
    GUICtrlSetData($Combo_Playlist_Songs_add, $Songs[$A_Anz1])
    Next
    GUICtrlSetData($Combo_Playlist_Songs_add, $Songs[1], $Songs[1])
    EndIf
    EndFunc
    Func _Delete_Song_from_Playlist()
    $read=GUICtrlRead($Combo_Playlist_Interpret_and_Songs_exist) ;;Interpret+Song in der Playlist
    $read2=GUICtrlRead($Combo_Playlists) ;;Playlist-datei
    $Count=1
    Do
    $Filereadline=Filereadline($PlaylistsMainPath& $read2, $count)
    If $Filereadline=$read then _FileWriteToLine($PlaylistsMainPath& $read2,$Count,"",1)
    $Count=$Count+1
    Until $Filereadline=$read
    _CreatePlaylistssongsandInterprets()
    EndFunc
    Func _Add_Playlist()
    FileWrite($PlaylistsMainPath&Inputbox("Playlistname"," "),"")
    _CreatePlaylists()
    EndFunc
    Func _CreatePlaylistssongsandInterprets()
    $Combo_Playlist_Interpret_and_Songs_Read = GUICtrlRead($Combo_Playlists)
    GUICtrlSetData($Combo_Playlist_Interpret_and_Songs_exist, "","")
    $count=1
    $Filereadline=Filereadline($PlaylistsMainPath & "\" & $Combo_Playlist_Interpret_and_Songs_Read, $count)
    Do
    GUICtrlSetData($Combo_Playlist_Interpret_and_Songs_exist, $Filereadline,$Filereadline)
    $Count=$Count+1
    $Filereadline=Filereadline($PlaylistsMainPath & "\" & $Combo_Playlist_Interpret_and_Songs_Read, $count)
    Until $Filereadline=""
    EndFunc
    Func _Delete_Playlist()
    FileDelete($PlaylistsMainPath&GUICtrlRead($Combo_Playlists))
    _CreatePlaylists()
    EndFunc
    Func _Add_Song2_Playlist()
    FileWriteLine($PlaylistsMainPath&GUICtrlRead($Combo_Playlists),Guictrlread($Combo_Playlist_Interprets_add)&"\"&GUICtrlRead($Combo_Playlist_Songs_add))
    _CreatePlaylistssongsandInterprets()
    EndFunc
    Func _Start_Playlist()
    $Count=1
    While $Count<> _FileCountLines($PlaylistsMainPath&GUICtrlRead($Combo_Playlists))+1
    $Open=_SoundOpen($MP3MainPath&Filereadline($PlaylistsMainPath&GUICtrlRead($Combo_Playlists),$Count))
    $S_lenght=_SoundLength($Open,2)
    _SoundPlay($Open)
    $Init=TimerInit()
    $Diff=TimerDiff($Init)
    While $Diff <=$S_lenght
    $Diff=TimerDiff($Init)
    Sleep(500)
    WEnd
    $Count=$Count+1
    WEnd
    EndFunc
    Func _CreatePlaylists()
    Global $Songlist = _FileListToArray($PlaylistsMainPath, "*", 0)
    If IsArray($Songlist) Then
    GUICtrlSetData($Combo_Playlists, "", "")
    For $A_Anz1 = 1 To UBound($Songlist) - 1
    GUICtrlSetData($Combo_Playlists,$Songlist[$A_Anz1])
    Next
    GUICtrlSetData($Combo_Playlists, $Songlist[1], $Songlist[1])
    EndIf
    EndFunc ;==>_CreateInterpret
    Func _CreateInterpret()
    Global $Interpret = _FileListToArray($Mp3MainPath, "*", 2)
    If IsArray($Interpret) Then
    GUICtrlSetData($Combo_Interpret, "", "")
    GUICtrlSetData($Combo_Playlist_Interprets_add, "", "")
    For $A_Anz1 = 1 To UBound($Interpret) - 1
    GUICtrlSetData($Combo_Interpret, $Interpret[$A_Anz1])
    GUICtrlSetData($Combo_Playlist_Interprets_add, $Interpret[$A_Anz1])
    Next
    GUICtrlSetData($Combo_Interpret, $Interpret[1], $Interpret[1])
    GUICtrlSetData($Combo_Playlist_Interprets_add, $Interpret[1], $Interpret[1])
    EndIf
    EndFunc ;==>_CreateInterpret
    Func Songs()
    $Interpret_Read = GUICtrlRead($Combo_Interpret)
    $Songs = _FileListToArray($Mp3MainPath & "\" & $Interpret_Read, "*", 1)
    If IsArray($Songs) Then
    GUICtrlSetData($Combo_Song, "", "")
    For $A_Anz1 = 1 To UBound($Songs) - 1
    GUICtrlSetData($Combo_Song, $Songs[$A_Anz1])
    Next
    GUICtrlSetData($Combo_Song, $Songs[1], $Songs[1])
    EndIf
    EndFunc ;==>Songs
    Func _play()
    If $Sound_opened<>"abc" then _SoundStop($Sound_opened)
    Global $Sound_opened=_SoundOpen ( $Mp3MainPath& GUICtrlRead($Combo_Interpret) &"\"& GUICtrlRead($Combo_Song) )
    _SoundPlay($Sound_opened)
    $Sond_lengh2=_SoundLength($Sound_opened,2)
    $Go_janein=1
    EndFunc
    Func _Pause()
    If $Pause_janein=1 then
    _SoundPause($Sound_opened)
    GUICtrlSetData($Pause,"Fortsetzen")
    $Pause_janein=2
    $Go_Janein=0
    Else
    _SoundResume ( $Sound_opened )
    GUICtrlSetData($Pause,"Pause")
    $Pause_janein=1
    $Go_Janein=1
    EndIf
    EndFunc
    Func _Stop()
    _SoundStop($Sound_opened)
    $Go_janein=5
    GUICtrlSetData($Loadbar,0)
    EndFunc
    Func _Springto()
    _SoundSeek($Sound_opened,1,1,1)
    EndFunc
    Func _setsound()
    SoundSetWaveVolume(Guictrlread($Soundvol))
    EndFunc
    Func _exit()
    Exit
    EndFunc ;==>_exit
    While 1
    If $Go_Janein=1 then
    $T_Init=TimerInit()
    While 1
    $Diff=TimerDiff($T_Init)
    If $Diff>=$Sond_lengh2/100 then
    GUICtrlSetData($Loadbar,GUICtrlRead($Loadbar)+1)
    ExitLoop
    EndIf
    WEnd
    Else
    Sleep(500)
    If $Go_janein=5 then GUICtrlSetData($Loadbar,0)
    EndIf
    WEnd

    [/autoit]


    Bei Fragen und gefundenen Bugs oder einer Verbesserung des Codes einfach posten :)
    Mfg Sevenby7