Seit längerem (ca. 2 wochen oder so .... ) bastel ich an meinem musikplayer rum
aber meine next funktion (/wiederholen funktion) will einfach nicht so wie ich (>.<)
her mein script:
Spoiler anzeigen
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=bilder\play.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Run_Obfuscator=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <GuiListView.au3>
#include <Sound.au3>
;##################
$SoundOpen = 1
$pause = 0
$soundP = 0
$wiederholen = 0
$PlayTitle = ""
$pos = "00:00:00"
$posold = "00:00:00"
$pos2 = 0
$IEOpen = 0
$listview = 0
$oWMP = 0
$scolor = " "
$scolor2 = " "
$PathSplit = ""
$Datei_Input = ""
$szDrive = ""
$szDir = ""
$szFName = ""
$szExt = ""
$ontop = 0
$soundbeendet = 0
;##################
#Region ### START Koda GUI section ### Form=c:\dokumente und einstellungen\gamer\desktop\form1.kxf
$Form1 = GUICreate("AlizameSound : Musik", 633, 454, 192, 124)
GUISetBkColor(0x000000)
$listview = GUICtrlCreateListView("Name|Endung|Ort", 40, 24, 529, 241,$LVS_EX_FULLROWSELECT)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 295)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 80)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 145)
GUICtrlSetState ($listview, $GUI_DROPACCEPTED)
GUICtrlSetBkColor(-1, 0x6A6A6A)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 35)
$Progress1 = GUICtrlCreateProgress(40, 288, 529, 9)
GUICtrlSetTip(-1, "Zum vor-/zurück- spulen auf die passende stelle klicken!")
$Label1 = GUICtrlCreateLabel("0", 576, 280, 11, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel(":", 584, 280, 7, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("00", 592, 280, 18, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$MenuItem1 = GUICtrlCreateMenu("&Einstellungen")
$MenuItem10 = GUICtrlCreateMenuItem("Immer im Vordergrund", $MenuItem1, -1 , 1)
$MenuItem2 = GUICtrlCreateMenu("Ü&ber")
$MenuItem8 = GUICtrlCreateMenuItem("AlizameSound v1.0", $MenuItem2)
$MenuItem9 = GUICtrlCreateMenuItem("© by Alizame", $MenuItem2)
$MenuItem3 = GUICtrlCreateMenu("&Credits")
$MenuItem4 = GUICtrlCreateMenuItem("Danke an:", $MenuItem3)
$MenuItem5 = GUICtrlCreateMenuItem("Jonathan Bennet und das AutoIt Team für AutoIt v3", $MenuItem3)
$MenuItem6 = GUICtrlCreateMenuItem("Gun-Food und peethebee für das Forum!!!", $MenuItem3)
$MenuItem7 = GUICtrlCreateMenuItem('Oscar für "Starplayer" (daraus konnrte ich viele beispiele entnehmen!) ', $MenuItem3)
$MenuItem8 = GUICtrlCreateMenuItem("Ach und alle User aus dem Forum xP", $MenuItem3)
;#######
$Icon1 = GUICtrlCreateIcon(@ScriptDir&"\bilder\links.ico", 0, 192, 328, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetTip(-1, "Vorheriger Tracks")
$Icon2 = GUICtrlCreateIcon(@ScriptDir&"\bilder\wiederholen.ico", 0, 232, 328, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetTip(-1, "Wiederholen")
$Icon3 = GUICtrlCreateIcon(@ScriptDir&"\bilder\play.ico", 0, 272, 328, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetTip(-1, "Play")
$Icon4 = GUICtrlCreateIcon(@ScriptDir&"\bilder\pause.ico", 0, 312, 328, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetTip(-1, "Pause")
$Icon5 = GUICtrlCreateIcon(@ScriptDir&"\bilder\stopp.ico", 0, 352, 328, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetTip(-1, "Stopp")
$Icon6 = GUICtrlCreateIcon(@ScriptDir&"\bilder\rechts.ico", 0, 392, 328, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetTip(-1, "Nächster Track")
$Icon7 = GUICtrlCreateIcon(@ScriptDir&"\bilder\add.ico", 0, 576, 32, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetTip(-1, "Hinzufügen")
$Icon8 = GUICtrlCreateIcon(@ScriptDir&"\bilder\delete.ico", 0, 576, 80, 40, 40, BitOR($SS_NOTIFY,$WS_GROUP))
GUICtrlSetTip(-1, "Löschen")
$Icon9 = GUICtrlCreateIcon(@ScriptDir&"\bilder\halblinks.ico", 0, 432, 328, 20, 40, BitOR($SS_NOTIFY,$WS_GROUP))
$Icon10 = GUICtrlCreateIcon(@ScriptDir&"\bilder\halbrechts.ico", 0, 176, 328, 20, 40, BitOR($SS_NOTIFY,$WS_GROUP))
;#######
$Label4 = GUICtrlCreateLabel("00:00:00", 288, 304, 60, 20)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg(0x004E, "_DoubleClickOnListView")
;#####
Func _DoubleClickOnListView($hWndGUI, $MsgID, $wParam, $lParam);Die Eigentliche Funktion
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam)
If @error Then Return
$event = DllStructGetData($tagNMHDR, 3); Checkt wie das EVENT aussieht
If $wParam = $listview Then;Wenn der Klick auf das ListView ging..
If $event = $NM_DBLCLK Then;.. Wenn es ein DoppelKlick war
; Hier kommt hin was er machen soll:
If $scolor2 = " " Or $scolor2 = 0 Then
$scolor = GUICtrlRead($listview)
GUICtrlSetBkColor($scolor, 0xEE9999)
$scolor2 = 1
ElseIf $scolor2 = 1 Then
GUICtrlSetBkColor( $scolor , 0x6A6A6A )
$scolor = GUICtrlRead($listview)
GUICtrlSetBkColor($scolor, 0xEE9999)
$scolor2 = 1
EndIf
$sz = GUICtrlRead(GUICtrlRead($listview))
If Not $sz = 0 Then
$PlayTitle = StringRegExpReplace($sz,"([^|]+)\|([^|]+)\|([^|]+)\|","\3\1\2")
;$aString = StringSplit($sz, "|", 2);Splittet den Rückgabestrimg auf und erstellt ein Array daraus
;$PlayTitle = $aString[2] & "|" & $aString[0] & "|" & $aString[1] ; $aSring[2] = Ort, $aSring[0] = Titel, $aString[1] = Endung
_SoundStop( $SoundOpen )
_SoundClose( $SoundOpen )
$soundP = 0
$SoundOpen = _SoundOpen( $PlayTitle )
_SoundPlay( $SoundOpen , 0 )
$soundP = 1
$soundbeendet = 0
EndIf
EndIf
EndIf
$tagNMHDR = 0
$event = 0
$lParam = 0
EndFunc ;==>_DoubleClickOnListView
;#####
Func _NewTicksToTimeSec($iTicks, $iStringFormat = False)
Local $iDays, $iHours, $iMins, $iSecs = Int($iTicks / 1000)
$iSecs = Mod($iSecs, 86400)
$iHours = Int($iSecs / 3600)
$iSecs = Mod($iSecs, 3600)
$iMins = Int($iSecs / 60)
$iSecs = Mod($iSecs, 60)
If $iStringFormat = False Then Return StringFormat(' %02i:%02i:%02i', $iHours, $iMins, $iSecs)
Local $aTime[4] = [$iHours, $iMins, $iSecs]
Return $iSecs
EndFunc ;==>_NewTicksToTime
Func _NewTicksToTimeMin($iTicks, $iStringFormat = False)
Local $iDays, $iHours, $iMins, $iSecs = Int($iTicks / 1000)
$iSecs = Mod($iSecs, 86400)
$iHours = Int($iSecs / 3600)
$iSecs = Mod($iSecs, 3600)
$iMins = Int($iSecs / 60)
$iSecs = Mod($iSecs, 60)
If $iStringFormat = False Then Return StringFormat(' %02i:%02i:%02i', $iHours, $iMins, $iSecs)
Local $aTime[4] = [$iHours, $iMins, $iSecs]
Return $iMins
EndFunc ;==>_NewTicksToTime
Func _NewTicksToTimeHour($iTicks, $iStringFormat = False)
Local $iDays, $iHours, $iMins, $iSecs = Int($iTicks / 1000)
$iSecs = Mod($iSecs, 86400)
$iHours = Int($iSecs / 3600)
$iSecs = Mod($iSecs, 3600)
$iMins = Int($iSecs / 60)
$iSecs = Mod($iSecs, 60)
If $iStringFormat = False Then Return StringFormat(' %02i:%02i:%02i', $iHours, $iMins, $iSecs)
Local $aTime[4] = [$iHours, $iMins, $iSecs]
Return $iHours
EndFunc ;==>_NewTicksToTime
Func _play ($item)
If $item = Default Then $item = 0
_GUICtrlListView_ClickItem($listview, $item , "left", False, 2)
EndFunc
$aPos = ControlGetPos($Form1, '', $Progress1)
While 1
Switch GUIGetMsg( )
Case $GUI_EVENT_CLOSE
_SoundClose( $SoundOpen )
Exit
Case $MenuItem10
If $ontop = 0 Then
$ontop = 1
WinSetOnTop("AlizameSound : Musik","",1)
GUICtrlSetState($MenuItem10,$GUI_CHECKED)
ElseIf $ontop = 1 Then
$ontop = 0
WinSetOnTop("AlizameSound : Musik","",0)
GUICtrlSetState($MenuItem10,$GUI_UNCHECKED)
EndIf
Case $GUI_EVENT_PRIMARYUP
$aInfo = GUIGetCursorInfo($Form1)
If $aInfo[4] = $Progress1 Then
$iPercent = 100 / $aPos[2] * ($aInfo[0] - $aPos[0])
GUICtrlSetData($Progress1, $iPercent)
$progpos = GUICtrlRead($Progress1)
If $soundP = 1 Then
; progressposition * länge /100
$length = _SoundLength( $SoundOpen , 2 )
$posset = $progpos * $length / 100
$iSecs1 = _NewTicksToTimeSec($posset,True)
$iMins1 = _NewTicksToTimeMin($posset,True)
$iHours1 = _NewTicksToTimeHour($posset,True)
_SoundSeek( $SoundOpen , $iHours1 , $iMins1 , $iSecs1 )
_SoundPlay( $SoundOpen )
EndIf
EndIf
Case $GUI_EVENT_DROPPED
Dim $szDrive, $szDir, $szFName, $szExt
$PathSplit = _PathSplit( @GUI_DragFile & "", $szDrive, $szDir, $szFName, $szExt)
GUICtrlCreateListViewItem ($PathSplit[3] & "|" & $PathSplit[4] & "|" & $PathSplit[1] & $PathSplit[2],$listview)
Case $Icon3
If $pause = 1 Then
_SoundResume($SoundOpen)
$soundP = 1
$pause = 0
ElseIf $pause = 0 Then
_play (Default)
EndIf
$puase = 0
Case $Icon2
$wiederholen = 1
Case $Icon4
If Not $SoundOpen = 1 Then
_SoundPause( $SoundOpen )
$pause = 1
$soundP = 0
EndIf
Case $Icon5
If Not $SoundOpen = 1 Then
_SoundStop( $SoundOpen )
_SoundClose( $SoundOpen )
$soundP = 0
EndIf
;links
Case $Icon1
MsgBox(0,"","links")
$scolor -= 1
;rechts
Case $Icon6
MsgBox(0,"","rechts")
$scolor += 1
Case $Icon7
$Datei_Input = FileOpenDialog("Dateien Hinzufügen", @MyDocumentsDir, "MP3 (*.mp3)|WAV (*.wav)|Alle Dateien (*.*)", 7)
If Not @error Then; Es wird nur verarbeitet wenn auch eine oder nehrere Dateien ausgefählt wurden
If StringInStr($Datei_Input, "|") Then ;Mehrer Dateien wurden ausgewählt
$Datei = StringSplit($Datei_Input, "|")
Dim $szDrive, $szDir, $szFName, $szExt
For $i = 2 To $Datei[0] Step 1; Starten bei 2 weil in 1 Der Dateipfad steht
ConsoleWrite($Datei[$i] & @CRLF)
$PathSplit = _PathSplit($Datei[1] & "\" & $Datei[$i], $szDrive, $szDir, $szFName, $szExt)
GUICtrlCreateListViewItem($PathSplit[3] & "|" & $PathSplit[4] & "|" & $PathSplit[1] & $PathSplit[2], $listview)
Next
Else; Es wurde nur 1 Datei ausgewählt
$PathSplit = _PathSplit($Datei_Input, $szDrive, $szDir, $szFName, $szExt)
GUICtrlCreateListViewItem($PathSplit[3] & "|" & $PathSplit[4] & "|" & $PathSplit[1] & $PathSplit[2], $listview)
EndIf
EndIf
Case $Icon8
GUICtrlDelete (GUICtrlRead ($listview))
Case $listview
_GUICtrlListView_SortItems ($listview, GUICtrlGetState ($listview))
EndSwitch
$length = _SoundLength( $SoundOpen , 2 )
$pos2 = _SoundPos( $SoundOpen , 2 )
$pos = _SoundPos( $SoundOpen , 1 )
;###pos#########
If $soundP = 1 Then
If $pos <> $posold Then
$ProgressPosition2 = 100 / $length * $pos2
GUICtrlSetData( $Progress1 , $ProgressPosition2 )
GUICtrlSetData( $Label4 , $pos )
$posold = $pos
EndIf
EndIf
;###pos###end###
;###sound zuende#########
If $soundP = 1 Then
$length = _SoundLength( $SoundOpen , 2 )
$pos2 = _SoundPos( $SoundOpen , 2 )
If $length = $pos2 Then
GUICtrlSetData( $Progress1 , 0 )
GUICtrlSetData( $Label4 , "00:00:00" )
GUICtrlSetBkColor($scolor, 0x6A6A6A)
$kitem = $scolor + 1
_play($kitem)
$soundP = 0
$soundbeendet = 1
EndIf
EndIf
;###sound zuende###end###
Sleep(5)
;###wiederholen#########
If $wiederholen = 1 Then
$itemcount = _GUICtrlListView_GetItemCount($listview)
If $itemcount = "" Then
$itemcount = 0
EndIf
MsgBox(0,"",$scolor&@CRLF&$itemcount)
_play (Default)
$wiederholen = 0
EndIf
;###wiederholen###end###
WEnd
; 100 * position / länge
; progressposition * länge /100
BITTE HELFT MIR!
Edit\\ icons vergessen : Player.rar