mp3 abspielen solange Form1 angezeigt wird

  • Guten Abend an alle im Forum,

    ich habe eine kurze Frage: Wie spiele ich eine mp3 ab, während Form 1 angezeigt wird bzw. schalte ich den Ton an und aus?

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>

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

    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 194, 58, 192, 124)
    $Button1 = GUICtrlCreateButton("Ton an", 16, 16, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Ton aus", 104, 16, 75, 25, 0)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit

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

    EndSwitch
    WEnd

    [/autoit]

    Vielen Dank und viele Grüße,
    TOYY1

    Einmal editiert, zuletzt von TOYY1 (22. September 2011 um 07:22)

  • So?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Sound.au3>

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

    $aSound = _SoundOpen(@ScriptDir & "\Test.mp3")

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

    $Form1 = GUICreate("Form1", 194, 58, 192, 124)
    $Button1 = GUICtrlCreateButton("Ton an", 16, 16, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Ton aus", 104, 16, 75, 25, 0)
    GUISetState()

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

    GUIRegisterMsg($WM_ACTIVATE, "_WM_ACTIVATE")

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

    _SoundPlay($aSound, 0)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

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

    Func _WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
    If $hWnd = $Form1 Then
    Switch $wParam
    Case 0
    _SoundPause($aSound)
    Case 1
    _SoundResume($aSound)
    EndSwitch
    EndIf
    EndFunc

    [/autoit]
  • WAHNSINN :) :) Danke name22...

    der Ton an / Ton aus Button reagiert jedoch nicht :(. Ich weiß grad nicht warum?

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Sound.au3>

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

    $aSound = _SoundOpen("C:\Test.mp3")

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

    $Form1 = GUICreate("Form1", 194, 58, 192, 124)
    $Button1 = GUICtrlCreateButton("Ton an", 16, 16, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Ton aus", 104, 16, 75, 25, 0)
    GUISetState()

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

    GUIRegisterMsg($WM_ACTIVATE, "_WM_ACTIVATE")

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

    _SoundPlay($aSound, 0)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    EndSwitch
    WEnd

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

    Func _WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam)
    If $hWnd = $Form1 Then
    Switch $wParam
    Case 0
    _SoundPause($aSound)
    Case 1
    _SoundResume($aSound)
    EndSwitch
    EndIf
    EndFunc

    [/autoit]

    Viele Grüße - TOLLES FORUM
    TOYY1

  • Zitat

    der Ton an / Ton aus Button reagiert jedoch nicht :(. Ich weiß grad nicht warum?


    Wenn du dich in ein Auto setzt, und dir wünschst zuhause zu sein fährt es auch nicht von alleine los, oder? :rolleyes:
    Du hast in der Hauptschleife den Buttons noch keinerlei Funktion zugewiesen, da ist es ja logisch, dass sie auch genau das machen (nämlich nichts).

  • Einfach mal 1 und 1 zusammenzählen: ;)

    Spoiler anzeigen
    [autoit]

    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Sound.au3>

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

    $aSound = _SoundOpen("C:\Test.mp3")

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

    $Form1 = GUICreate("Form1", 194, 58, 192, 124)
    $Button1 = GUICtrlCreateButton("Ton an", 16, 16, 75, 25, 0)
    $Button2 = GUICtrlCreateButton("Ton aus", 104, 16, 75, 25, 0)
    GUISetState()

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

    _SoundPlay($aSound, 0)

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $Button1
    _SoundResume($aSound)
    Case $Button2
    _SoundPause($aSound)
    EndSwitch
    WEnd

    [/autoit]

    MfG hellboy

    [autoit]

    Do
    _help($user)
    Until $questions = 0

    [/autoit]

    Meine Werke:
    Ste`s Web-Radio