Hallo Leute,
ist es irgendwie möglich die Progress Bar beim anklicken zu verstellen?
Ich habe hier einen Musikplayer bei dem ich gerne den Song mit anklicken auf die Progress Bar verstellen möchte.
So ähnlich wie vor oder rückspulen bei Media Player.
Leider habe ich absolut kein Plan wie ich das realisieren könnte.
Vielleicht hat jemand eine Idee und kann mir da weiterhelfen?
Hier bis jetzt mein CODE
Spoiler anzeigen
#include <GUIConstantsEx.au3>
#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Sound.au3>
Global $XS_n
[/autoit] [autoit][/autoit] [autoit]#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Mp3 Player", 333, 437, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_SYSMENU,$WS_POPUP,$WS_GROUP,$WS_CLIPSIBLINGS))
FileInstall("C:\Windows\Web\Screen\img105.jpg", ".\Background.jpeg")
$Pic1 = GUICtrlCreatePic("Background.jpeg", 0, 0, 332, 436, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUICtrlSetState(-1, $GUI_DISABLE)
$DateiButton = GUICtrlCreateButton("...", 8, 8, 60, 25)
$PlayButton = GUICtrlCreateButton("Play", 74, 8, 60, 25)
$PauseButton = GUICtrlCreateButton("Pause", 139, 8, 60, 25)
$StopButton = GUICtrlCreateButton("Stop", 202, 8, 60, 25)
$ExitButton = GUICtrlCreateButton("Exit", 266, 8, 60, 25)
$DateiLabel = GUICtrlCreateLabel("Keine Datei ausgewählt", 8, 40, 319, 40)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x000000)
$ZeitLabel = GUICtrlCreateLabel("Zeit: 0 - Länge: 0 - Übrig: 0", 8, 80, 319, 17)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetBkColor(-1, 0x000000)
$Progress1 = GUICtrlCreateProgress(8, 100, 319, 17)
$Lautstaerke = GUICtrlCreateSlider(8, 392, 318, 37)
GUICtrlSetData(-1, 1)
GUICtrlSetBkColor(-1,0x000000)
XPStyleToggle(1);turn xp themes off
$ReiseJerusalem = GUICtrlCreateCheckbox("Spiel: Reise nach Jerusalem", 8, 360, 319, 34)
GUICtrlSetColor($ReiseJerusalem, $COLOR_WHITE)
GUICtrlSetBkColor($ReiseJerusalem, $GUI_BKCOLOR_TRANSPARENT)
XPStyleToggle(0);turn XP themes on again
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $hSound, $lol, $Lenght, $Pos, $Paused = False
Local $Ordner = 'X:\Musik'
Local $lol = $Ordner & '\Russische Musik\ä¿ß¬«ÔѬá 80-Õ.ùáßÔý1\03_-_Afric_Simone_-_Hafanana.mp3'
GUICtrlSetData($DateiLabel, $lol)
$Read = GUICtrlRead($Lautstaerke)
SoundSetWaveVolume($Read)
While Sleep(10)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_SoundStop($hSound)
Exit
Case $DateiButton
;~ $lol = FileOpenDialog("", @UserProfileDir & "\Music", "(*.mp3)", 1)
$lol = FileOpenDialog("", $Ordner, "(*.mp3)", 1)
GUICtrlSetData($DateiLabel, $lol)
Case $PlayButton
If IsArray($hSound) And $hSound[3] > 0 Then _SoundClose($hSound)
$hSound = _SoundOpen($lol)
If @error Then
MsgBox(48, "Fehler", "Es wurde keine Datei ausgewählt!")
Else
$Lenght = _SoundLength($hSound)
_SoundPlay($hSound)
$Paused = False
EndIf
GUICtrlSetData($DateiLabel, $lol)
If _IsChecked($ReiseJerusalem) Then $Position = _SoundPos($hSound, 2) + Random(15, 30, 1)*1000
Case $StopButton
If IsArray($hSound) And $hSound[3] > 0 Then
_SoundStop($hSound)
_SoundClose($hSound)
EndIf
Case $ExitButton
_SoundStop($hSound)
Exit
Case $PauseButton
$Paused = Not $Paused
If $Paused = True Then _SoundPause($hSound)
If $Paused = False Then
_SoundResume ($hSound)
If _IsChecked($ReiseJerusalem) Then $Position = _SoundPos($hSound, 2) + Random(15, 30, 1)*1000
EndIf
Case $Lautstaerke
$Read = GUICtrlRead($Lautstaerke)
SoundSetWaveVolume($Read)
Case $ReiseJerusalem
$Position = _SoundPos($hSound, 2) + Random(15, 30, 1)*1000
Case $Progress1
Hier sollte irgendwie was passieren
EndSwitch
$Maximale_Laenge = _SoundLength($hSound, 2)
$Aktuelle_Position = _SoundPos($hSound, 2)
$Fortschritt = $Aktuelle_Position * 100 / $Maximale_Laenge
If (GUICtrlRead($Progress1) + 1) <> $Fortschritt Then
GUICtrlSetData($Progress1, $Fortschritt)
EndIf
$Pos = _SoundPos($hSound)
Local $Hours, $Mins, $Secs
__SoundTicksToTime($Maximale_Laenge - $Aktuelle_Position, $Hours, $Mins, $Secs)
$Left = StringFormat("%02i:%02i:%02i", $Hours, $Mins, $Secs)
$bla = "Zeit: " & $Pos & " - Länge: " & $Lenght & " - Übrig: " & $Left
If GUICtrlRead($ZeitLabel) <> $bla Then GUICtrlSetData($ZeitLabel, $bla)
If _IsChecked($ReiseJerusalem) And _SoundPos($hSound, 2) > $Position Then
_SoundPause($hSound)
$Paused = True
$Position = _SoundPos($hSound, 2) + Random(15, 30, 1)*1000
EndIf
If _IsChecked($ReiseJerusalem) Then ConsoleWrite("Aktuelle Position: " & Sec2Time(_SoundPos($hSound, 2)/1000) & ' bis ' & Sec2Time($Position/1000) & " _SoundStatus: " & _SoundStatus($hSound) & @CRLF)
WEnd
Func XPStyleToggle($Off = 1)
If Not StringInStr(@OSTYPE, "WIN32_NT") Then Return 0
If $Off Then
$XS_n = DllCall("uxtheme.dll", "int", "GetThemeAppProperties")
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", 0)
Return 1
ElseIf IsArray($XS_n) Then
DllCall("uxtheme.dll", "none", "SetThemeAppProperties", "int", $XS_n[0])
$XS_n = ""
Return 1
EndIf
Return 0
EndFunc
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
If ($hWnd = $Form1) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc
Func Sec2Time($nr_sec)
$sec2time_hour = Int($nr_sec / 3600)
$sec2time_min = Int(($nr_sec - $sec2time_hour * 3600) / 60)
$sec2time_sec = $nr_sec - $sec2time_hour * 3600 - $sec2time_min * 60
Return StringFormat('%02d:%02d:%02d', $sec2time_hour, $sec2time_min, $sec2time_sec)
EndFunc ;==>Sec2Time
Func _IsChecked($iControlID)
Return BitAND(GUICtrlRead($iControlID), $GUI_CHECKED) = $GUI_CHECKED
EndFunc ;==>_IsChecked