Musikplayer

  • Hey Leute,

    Ich hab mit heute ran gemacht einen kleinen Musikplayer zu schreiben!

    Aber mir kommen einige probleme entgegen!

    [autoit]

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

    [/autoit][autoit][/autoit][autoit]

    Global $aSnd_id
    #Region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Musikplayer by [CF[*Gaming]", 501, 154, 192, 124)
    $Button1 = GUICtrlCreateButton("Play", 8, 112, 113, 33, BitOR($BS_ICON,$WS_GROUP))
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $Button2 = GUICtrlCreateButton("STOP", 128, 112, 113, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $Button3 = GUICtrlCreateButton("Pause", 250, 112, 113, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $Slider1 = GUICtrlCreateSlider(8, 16, 481, 25)
    $Label1 = GUICtrlCreateLabel("00:00", 88, 56, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel("00:00", 320, 56, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label3 = GUICtrlCreateLabel("/", 248, 56, 12, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    While 1
    _GUICtrlSlider_SetPos($Slider1, _SoundLength($aSnd_id))
    GUICtrlSetData($Label1, _SoundPos($aSnd_id));Zeigt die wie weite das Lied schon ist! Flaggert noch, Ich suche noch eine andere Lösung
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    $sFile = FileOpenDialog("Musikplayer by [CF[*Gaming]","E:\Music", "Musik (*.mp3)", 1 );Öffnet eine .mp3-Datei
    ;~ WinSetTitle( "Musikplayer by [CF[*Gaming]", "", "Musikplayer by [CF[*Gaming]\" & $sFile)
    $aSnd_id = _SoundOpen($SFile);Öffnet eine die .mp3 aus $File
    GUICtrlSetData($Label2, _SoundLength($aSnd_id));Gibt die Länge des Liedes zurück
    _GUICtrlSlider_setRangeMax($Slider1, _SoundLength($aSnd_id))
    _SoundPlay($aSnd_id);Startet das Lied
    ;Hier soll noch eine Funktion hin mit der aus $Button1 ein anderer Button wird der dann Der Pause Button ist
    Case $Button2
    _SoundStop($aSnd_id);Stopp das Lied
    Case $Button3
    _SoundPause($aSnd_id);Pausiert das Lied
    EndSwitch
    WEnd

    [/autoit]

    1. Wie mache ich das Am Anfang bei dem einen Label nicht 0 Steht sonder 00:00?

    2.Wie kann man das Flakkern von den Labels verhindern?

    3.Wie mach ich das der Slider immmer mit läuft? also das der so lang braucht wie das Lied oder sollte ich da eher einen Progress verwenden?

    4. Also 1 Button (play,pause und play nach der Pause) Beim Ersten Mal drauf klicken soll sich der FileopenDialog Aktiviren damit man eine Lied aus waählen kann. Dann soll aus dem Button play ein Button Pause werden. Klickt man da drauf soll das Leidt Pausieren und aus dem Button soll wieder play werden. wenn man aber jetzt auf den Button kliegt soll sich nicht mehr der FileopenDialog Aktivieren sonder das Aktuelle Lied soll einfach weiter gehen!

    Das Währen erstmal mal die 4 hauptsächlichen Bugs. ich weis euch werden noch ein paa mehr Bugs auf fahlen aber die sind ertsmal nich wichtig!

    Der 3Button(Pause) soll dann Später weg sein weil der dan ja mit dem play Buuton sein soll!

    MFg CF*Gaming

  • 2.Wie kann man das Flakkern von den Labels verhindern?

    [autoit]

    AdlibRegister

    [/autoit]

    Anschauen

    3.Wie mach ich das der Slider immmer mit läuft? also das der so lang braucht wie das Lied oder sollte ich da eher einen Progress verwenden?


    Kommt drauf an ob du dem User erlaubst zu einer x beliebigen Stelle im Lied zu springen

  • 1. Versteh ich nich was mir das bringen soll?

    2. Gefixt

    3. Ja es soll schon möglich sein zu einer bestimmten Stelle zu Springen!

  • So fertig. Allerdings sind diese _Sound Funktionen einfach zum brechen. An eine Position springen funzt irgentwie nicht. Naja egal.
    Und gewöhn dir mal bitte an den Variablen vernünftige Namen zu geben.

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <Sound.au3>
    #include <WinAPI.au3>
    $tCoords = DllStructCreate("int X;int Y")
    Global $sFile, $iSoundID

    [/autoit] [autoit][/autoit] [autoit]

    $hGUI = GUICreate("Musikplayer by [CF[*Gaming]", 501, 154, 192, 124)
    $cPlay = GUICtrlCreateButton("Play", 8, 112, 113, 33, $BS_ICON)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $cStop = GUICtrlCreateButton("STOP", 128, 112, 113, 33)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $cPause = GUICtrlCreateButton("Pause", 250, 112, 113, 33)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $cSlider = GUICtrlCreateSlider(8, 16, 481, 25)

    [/autoit] [autoit][/autoit] [autoit]

    $cTime = GUICtrlCreateLabel("00:00", 88, 56, 200, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    AdlibRegister("Update", 1000)
    GUISetState(@SW_SHOW)
    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case -3
    Exit
    Case $cPlay
    If $sFile = "" Then
    $sFile = FileOpenDialog("Musikdatei wählen", @DesktopDir, "Mp3 (*.mp3)", 1 + 2)
    If @error Then ContinueLoop
    $iSoundID = _SoundOpen($sFile)
    If @error Then
    MsgBox(16, "Error", "Sound konnte nicht geöffnet werden!")
    $sFile = ""
    EndIf
    EndIf
    _SoundPlay($iSoundID)
    Case $cPause
    _SoundPause($iSoundID)
    Case $cStop
    _SoundStop($iSoundID)
    Case $cSlider
    $iLen = _SoundLength($iSoundID)
    $iPos = GUICtrlRead($cSlider)
    $iPos = _ms2time2(Int(($iPos * $iLen) / 100))
    _SoundSeek($iSoundID,Int($iPos[0]),Int($iPos[1]),Int($iPos[2]))
    _SoundPlay($iSoundID)
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func Update()
    $iLen = _SoundLength($iSoundID, 2)
    $iPos = _SoundPos($iSoundID, 2)
    GUICtrlSetData($cTime, _ms2time($iPos) & "/" & _ms2time($iLen))

    [/autoit] [autoit][/autoit] [autoit]

    $aPos = MouseGetPos()
    DllStructSetData($tCoords, "X", $aPos[0])
    DllStructSetData($tCoords, "Y", $aPos[1])
    _WinAPI_ScreenToClient($hGUI, $tCoords)
    $iX = DllStructGetData($tCoords, "X")
    $iY = DllStructGetData($tCoords, "Y")
    If Not _RectCollision(8, 16, 481, 25, $iX, $iY, 0, 0) Then GUICtrlSetData($cSlider, Int(($iPos * 100) / $iLen))
    EndFunc ;==>Update

    [/autoit] [autoit][/autoit] [autoit]

    Func _RectCollision($iX1, $iY1, $iWidth1, $iHeight1, $iX2, $iY2, $iWidth2, $iHeight2)
    ;Author: Faweyr
    Return $iX1 + $iWidth1 > $iX2 And $iX1 < $iX2 + $iWidth2 And $iY1 + $iHeight1 > $iY2 And $iY1 < $iY2 + $iHeight2
    EndFunc ;==>_RectCollision

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _ms2time($iMSec)
    ;By Sprenger120
    Local $iSec
    If $iMSec < 1000 Then Return "00:00"
    $iMSec /= 1000
    $iSec = Mod($iMSec, 60)
    If $iSec < 0 Then $iSec = 0
    $iMSec -= $iSec
    $iMSec /= 60
    $iMSec = Int($iMSec)
    $iSec = Int($iSec)
    If $iMSec < 10 Then $iMSec = "0" & $iMSec
    If $iSec < 10 Then $iSec = "0" & $iSec
    Return $iMSec & ":" & $iSec
    EndFunc ;==>_ms2time

    [/autoit] [autoit][/autoit] [autoit]

    ;By SEuBo
    Func _ms2time2($iSec)
    $iSec /= 1000
    Local $iRetH = 0, $iRetM = 0, $iRetS = 0
    If $iSec / 3600 >= 1 Then
    $iRetH = Floor($iSec / 3600)
    $iSec = Mod($iSec, 3600)
    EndIf
    If $iSec / 60 >= 1 Then
    $iRetM = Floor($iSec / 60)
    $iSec = Mod($iSec, 60)
    EndIf
    $iRetS = $iSec
    Dim $aTmp[3] = [$iRetH, $iRetM, $iRetS]
    Return $aTmp
    EndFunc ;==>_ms2time2

    [/autoit]

    Sry für den Doppelpost.

  • okay danke :D

    zu den Variablen ich weis immer nich wie ich die nennen soll :rofl:

    So jetzt fehlt ja nur noch das mit den Buutons kann mir da jetzt noch einer sagen wie ich das machen muss_?

  • Hallo CF,

    hier eine Lösung, die mit 2 Buttons auskommt: [spoiler]

    [autoit]

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

    [/autoit][autoit][/autoit][autoit]

    Global $aSnd_id, $iLength, $bSlider = True
    #region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Musikplayer by [CF[*Gaming]", 501, 154, 192, 124)
    $idBtnOpenPlayPause = GUICtrlCreateButton("&Öffnen", 8, 112, 113, 33, BitOR($BS_ICON, $WS_GROUP))
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $idBtnStop = GUICtrlCreateButton("&STOP", 128, 112, 113, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    ;$Button3 = GUICtrlCreateButton("Pause", 250, 112, 113, 33, $WS_GROUP);
    ;GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $idSldrPos = GUICtrlCreateSlider(8, 16, 481, 25);, BitOR($GUI_SS_DEFAULT_SLIDER, $SS_NOTIFY, $TBS_Bottom, $TBS_ENABLESELRANGE, $TBS_TOOLTIPS, $TBS_AUTOTICKS))
    GUICtrlSetLimit(100, 1)
    $Label1 = GUICtrlCreateLabel("00:00", 88, 56, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel("00:00", 320, 56, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label3 = GUICtrlCreateLabel("/", 248, 56, 12, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

    [/autoit][autoit][/autoit][autoit]

    AdlibRegister("_GetPos", 1000)

    [/autoit][autoit][/autoit][autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $idBtnOpenPlayPause
    $sBtnText = GUICtrlRead($idBtnOpenPlayPause)
    Switch $sBtnText
    Case "&Öffnen"
    $sFile = FileOpenDialog("Musikplayer by [CF[*Gaming]", "E:\Music", "Musik (*.mp3)", 1);Öffnet eine .mp3-Datei
    ;~ WinSetTitle( "Musikplayer by [CF[*Gaming]", "", "Musikplayer by [CF[*Gaming]\" & $sFile)
    $aSnd_id = _SoundOpen($sFile);Öffnet eine die .mp3 aus $File
    GUICtrlSetData($Label2, _SoundLength($aSnd_id));Gibt die Länge des Liedes zurück
    _SoundPlay($aSnd_id);Startet das Lied
    GUICtrlSetData($idBtnOpenPlayPause, "&Pause")
    Case "&Play"
    _SoundResume($aSnd_id)
    GUICtrlSetData($idBtnOpenPlayPause, "&Pause")
    Case "&Pause"
    _SoundPause($aSnd_id)
    GUICtrlSetData($idBtnOpenPlayPause, "&Play")
    EndSwitch
    Case $idSldrPos
    $bSlider =False
    $iSS = Round($iLength / 100 * GUICtrlRead($idSldrPos),0)
    consolewrite("Neue Pos in Seknden:" & $iSS & @CRLF)
    Local $iHH = Int($iSS / 3600)
    $iSS = Mod($iSS, 3600)
    Local $iMM = Int($iSS / 60)
    $iSS = Mod($iSS, 60)
    consolewrite($iHH & ":" & $iMM & ":" & $iSS & @CRLF)
    _SoundStop($aSnd_id)
    _SoundSeek($aSnd_id, $iHH, $iMM, $iSS)
    _SoundPlay($aSnd_id)
    $bSlider =True
    Case $idBtnStop
    _SoundStop($aSnd_id);Stopp das Lied
    GUICtrlSetData($idBtnOpenPlayPause, "&Öffnen")
    EndSwitch
    WEnd

    [/autoit][autoit][/autoit][autoit]

    Func _GetPos()
    $iPos = _SoundPos($aSnd_id, 2) / 1000
    $iLength = _SoundLength($aSnd_id, 2) / 1000
    $iPer = $iPos / $iLength * 100
    GUICtrlSetData($Label1, _SoundPos($aSnd_id));Zeigt die wie weite das Lied schon ist
    if $bSlider Then GUICtrlSetData($idSldrPos, $iPer)
    EndFunc ;==>_GetPos

    [/autoit]

    [spoiler]

    am Position setzen anhand des Sliders scheitere ich derzeit noch. Viel Spass damit

    Edit: Skript ausgetauscht, der Slider funktioniert jetzt halbwegs

    mfg (Auto)Bert

    Einmal editiert, zuletzt von AutoBert (19. Juli 2010 um 22:14)

  • Ah okay danke So funktionier es mit den Buttons::


    Ja das mit dem Slider scheint unmöglich zu sein mit _soundplay usw..

    Ich glaub mit der Bass.au3 geht das

  • Das Problem liegt ja nur dabei das dier werte von _soundpos in 00:00:00 zurück geben werden:(

  • Oh:D

    Naja ok dann liegt es schon mal nich daran..
    @sprenger: Ich hab jetzt schon bisschen rumprobiret aber ich krieg deine Funktion(Also das da 00:00 staht 0 steht) in das Scirpt von Autobert reinzubauen
    aber es kommen nur wirre sachen raus:(

  • [

    Spoiler anzeigen
    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <ProgressConstants.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <Sound.au3>
    #include <Guislider.au3>
    Global $aSnd_id
    #region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Musikplayer by [CF[*Gaming]", 501, 154, 192, 124)
    $idBtnOpenPlayPause = GUICtrlCreateButton("&Öffnen", 8, 112, 113, 33, BitOR($BS_ICON, $WS_GROUP))
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $idBtnStop = GUICtrlCreateButton("&STOP", 128, 112, 113, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $idSldrPos = GUICtrlCreateSlider(8, 16, 481, 25)
    GUICtrlSetLimit(-1, 100)
    ;_GUICtrlSlider_SetTicFreq($idsliderPos, 1)
    $Label1 = GUICtrlCreateLabel("00:00:00", 136, 56, 108, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel("00:00:00", 264, 56, 108, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label3 = GUICtrlCreateLabel("/", 248, 56, 12, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###
    AdlibRegister("_GetPos", 500)
    While 1
    $idSldrPos = _SoundPos($aSnd_id)
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $idBtnOpenPlayPause
    $sBtnText = GUICtrlRead($idBtnOpenPlayPause)
    Switch $sBtnText
    Case "&Öffnen"
    $sFile = FileOpenDialog("Musikplayer by [CF[*Gaming]", "E:\Music", "Musik (*.mp3)", 1);Öffnet eine .mp3-Datei
    ;~ WinSetTitle( "Musikplayer by [CF[*Gaming]", "", "Musikplayer by [CF[*Gaming]\" & $sFile)
    $aSnd_id = _SoundOpen($sFile);Öffnet eine die .mp3 aus $File
    GUICtrlSetData($Label2, _SoundLength($aSnd_id));Gibt die Länge des Liedes zurück
    _SoundPlay($aSnd_id);Startet das Lied
    GUICtrlSetData($idBtnOpenPlayPause, "&Pause")
    Case "&Play"
    _SoundResume($aSnd_id)
    GUICtrlSetData($idBtnOpenPlayPause, "&Pause")
    Case "&Pause"
    _SoundPause($aSnd_id)
    GUICtrlSetData($idBtnOpenPlayPause, "&Play")
    EndSwitch
    Case $idBtnStop
    _SoundStop($aSnd_id);Stopp das Lied
    GUICtrlSetData($idBtnOpenPlayPause, "&Öffnen")
    ; Case $Button3
    ; _SoundPause($aSnd_id);Pausiert das Lied
    EndSwitch
    WEnd
    Func _GetPos()
    $iPos = _SoundPos($aSnd_id, 2)
    $iLength = _SoundLength($aSnd_id, 2)
    $iPer = $iPos / $iLength * 100
    GUICtrlSetData($Label1, _SoundPos($aSnd_id));Zeigt die wie weite das Lied schon ist
    GUICtrlSetData($idSldrPos, $iPer)
    EndFunc ;==>_GetPos

    [/autoit]
  • Hallo CF

    das Problem liegt nicht am SLider: Heir eine Lösung die halbwegs funktioniert:

    Spoiler anzeigen
    [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    Global $aSnd_id, $iLength, $bSlider = True
    #region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Musikplayer by [CF[*Gaming]", 501, 154, 192, 124)
    $idBtnOpenPlayPause = GUICtrlCreateButton("&Öffnen", 8, 112, 113, 33, BitOR($BS_ICON, $WS_GROUP))
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $idBtnStop = GUICtrlCreateButton("&STOP", 128, 112, 113, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    ;$Button3 = GUICtrlCreateButton("Pause", 250, 112, 113, 33, $WS_GROUP);
    ;GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $idSldrPos = GUICtrlCreateSlider(8, 16, 481, 25);, BitOR($GUI_SS_DEFAULT_SLIDER, $SS_NOTIFY, $TBS_Bottom, $TBS_ENABLESELRANGE, $TBS_TOOLTIPS, $TBS_AUTOTICKS))
    GUICtrlSetLimit(100, 1)
    $Label1 = GUICtrlCreateLabel("00:00", 88, 56, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel("00:00", 320, 56, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label3 = GUICtrlCreateLabel("/", 248, 56, 12, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    AdlibRegister("_GetPos", 1000)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $idBtnOpenPlayPause
    $sBtnText = GUICtrlRead($idBtnOpenPlayPause)
    Switch $sBtnText
    Case "&Öffnen"
    $sFile = FileOpenDialog("Musikplayer by [CF[*Gaming]", "E:\Music", "Musik (*.mp3)", 1);Öffnet eine .mp3-Datei
    ;~ WinSetTitle( "Musikplayer by [CF[*Gaming]", "", "Musikplayer by [CF[*Gaming]\" & $sFile)
    $aSnd_id = _SoundOpen($sFile);Öffnet eine die .mp3 aus $File
    GUICtrlSetData($Label2, _SoundLength($aSnd_id));Gibt die Länge des Liedes zurück
    _SoundPlay($aSnd_id);Startet das Lied
    GUICtrlSetData($idBtnOpenPlayPause, "&Pause")
    Case "&Play"
    _SoundResume($aSnd_id)
    GUICtrlSetData($idBtnOpenPlayPause, "&Pause")
    Case "&Pause"
    _SoundPause($aSnd_id)
    GUICtrlSetData($idBtnOpenPlayPause, "&Play")
    EndSwitch
    Case $idSldrPos
    $bSlider =False
    $iSS = Round($iLength / 100 * GUICtrlRead($idSldrPos),0)
    consolewrite("Neue Pos in Seknden:" & $iSS & @CRLF)
    Local $iHH = Int($iSS / 3600)
    $iSS = Mod($iSS, 3600)
    Local $iMM = Int($iSS / 60)
    $iSS = Mod($iSS, 60)
    consolewrite($iHH & ":" & $iMM & ":" & $iSS & @CRLF)
    _SoundStop($aSnd_id)
    _SoundSeek($aSnd_id, $iHH, $iMM, $iSS)
    _SoundPlay($aSnd_id)
    $bSlider =True
    Case $idBtnStop
    _SoundStop($aSnd_id);Stopp das Lied
    GUICtrlSetData($idBtnOpenPlayPause, "&Öffnen")
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetPos()
    $iPos = _SoundPos($aSnd_id, 2) / 1000
    $iLength = _SoundLength($aSnd_id, 2) / 1000
    $iPer = $iPos / $iLength * 100
    GUICtrlSetData($Label1, _SoundPos($aSnd_id));Zeigt die wie weite das Lied schon ist
    if $bSlider Then GUICtrlSetData($idSldrPos, $iPer)
    EndFunc ;==>_GetPos

    [/autoit]

    mfg (Auto)Bert

  • Hallo CF,

    ich habe das Skript nochmal überarbeitet, der Slider lässt sich jetzt besser bedienen:

    Spoiler anzeigen
    [autoit]

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

    [/autoit] [autoit][/autoit] [autoit]

    Global $aSnd_id, $iLength, $bSlider = True
    #region ### START Koda GUI section ### Form=
    $Form1_1 = GUICreate("Musikplayer by [CF[*Gaming]", 501, 154, 192, 124)
    $idBtnOpenPlayPause = GUICtrlCreateButton("&Öffnen", 8, 112, 113, 33, BitOR($BS_ICON, $WS_GROUP))
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $idBtnStop = GUICtrlCreateButton("&STOP", 128, 112, 113, 33, $WS_GROUP)
    GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    ;$Button3 = GUICtrlCreateButton("Pause", 250, 112, 113, 33, $WS_GROUP);
    ;GUICtrlSetFont(-1, 18, 400, 0, "X-Files")
    $idSldrPos = GUICtrlCreateSlider(8, 16, 481, 25, $TBS_TOOLTIPS)
    GUICtrlSetLimit($idSldrPos,100, 1)
    $Label1 = GUICtrlCreateLabel("00:00", 88, 56, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label2 = GUICtrlCreateLabel("00:00", 320, 56, 100, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    $Label3 = GUICtrlCreateLabel("/", 248, 56, 12, 36)
    GUICtrlSetFont(-1, 20, 400, 0, "Arial")
    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

    [/autoit] [autoit][/autoit] [autoit]

    AdlibRegister("_GetPos", 1000)

    [/autoit] [autoit][/autoit] [autoit]

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $idBtnOpenPlayPause
    $sBtnText = GUICtrlRead($idBtnOpenPlayPause)
    Switch $sBtnText
    Case "&Öffnen"
    $sFile = FileOpenDialog("Musikplayer by [CF[*Gaming]", "E:\Music", "Musik (*.mp3)", 1);Öffnet eine .mp3-Datei
    ;~ WinSetTitle( "Musikplayer by [CF[*Gaming]", "", "Musikplayer by [CF[*Gaming]\" & $sFile)
    $aSnd_id = _SoundOpen($sFile);Öffnet eine die .mp3 aus $File
    GUICtrlSetData($Label2, _SoundLength($aSnd_id));Gibt die Länge des Liedes zurück
    $iLength = _SoundLength($aSnd_id, 2) / 1000
    GUICtrlSetLimit($idSldrPos,$iLength, 1)
    _SoundPlay($aSnd_id);Startet das Lied
    GUICtrlSetData($idBtnOpenPlayPause, "&Pause")
    Case "&Play"
    _SoundResume($aSnd_id)
    GUICtrlSetData($idBtnOpenPlayPause, "&Pause")
    Case "&Pause"
    _SoundPause($aSnd_id)
    GUICtrlSetData($idBtnOpenPlayPause, "&Play")
    EndSwitch
    Case $GUI_EVENT_PRIMARYDOWN
    $bSlider = False
    Case $GUI_EVENT_PRIMARYUP
    $bSlider = True
    Case $idSldrPos
    $bSlider =False
    $iSS = GUICtrlRead($idSldrPos)
    consolewrite("Neue Pos in Seknden:" & $iSS & @CRLF)
    Local $iHH = Int($iSS / 3600)
    $iSS = Mod($iSS, 3600)
    Local $iMM = Int($iSS / 60)
    $iSS = Mod($iSS, 60)
    consolewrite($iHH & ":" & $iMM & ":" & $iSS & @CRLF)
    _SoundSeek($aSnd_id, $iHH, $iMM, $iSS)
    _SoundPlay($aSnd_id)
    $bSlider =True
    Case $idBtnStop
    _SoundStop($aSnd_id);Stopp das Lied
    GUICtrlSetData($idBtnOpenPlayPause, "&Öffnen")
    EndSwitch
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _GetPos()
    $iPos = _SoundPos($aSnd_id, 2) / 1000
    GUICtrlSetData($Label1, _SoundPos($aSnd_id));Zeigt die wie weite das Lied schon ist
    if $bSlider Then GUICtrlSetData($idSldrPos, $iPos)
    EndFunc ;==>_GetPos

    [/autoit]

    zusätzlich wird die Zeit in Sekunden beim Ziehen des Sliders angezeigt,

    mfg (Auto)Bert

  • aaah Perfekt:D

    Autobert :love:

    :rofl:


    Edit: Wenn das Lied zu ende is Soll der Button wieder auf Öffnen gehen aber wie Krieg ich raus das das Leid zu ende is?

    Bitte nich im Scipt bercihtigen sondern nur sagen wie ic das raus krieg:D Ich muss ja auch ma selbst was MAchen:D