_soundplay() problem

  • Hi wenn ich hier bei _soundplay die 0 auf 1 setzte spielt es zwar ab aber ich kann nicht stoppen etc.
    wenn es auf 0 bleibt spielt es garnicht ab.
    Was ist falsch ?

    [autoit]

    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Sound.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 269, 245, 286, 300)
    $MenuItem1 = GUICtrlCreateMenu("Datei")
    $MenuItem4 = GUICtrlCreateMenuItem("Öffnen", $MenuItem1)
    $MenuItem3 = GUICtrlCreateMenuItem("", $MenuItem1)
    $MenuItem2 = GUICtrlCreateMenuItem("Beenden", $MenuItem1)
    $Button1 = GUICtrlCreateButton("Play", 8, 168, 43, 41, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Stop", 56, 168, 43, 41, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Dim $var=false

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $MenuItem4
    $Data=FileOpenDialog("Datei","","Datei (*.mp3)")

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

    Case $MenuItem2
    Exit
    Case $Button1
    $SoundPlay=_SoundOpen($Data,"Notify")
    _SoundPlay($SoundPlay,0)
    _SoundClose($SoundPlay)
    Case $Button2
    _SoundPause($SoundPlay)

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

    EndSwitch
    WEnd

    [/autoit]
  • So sollte es was werden:

    Spoiler anzeigen
    [autoit]


    #include <ButtonConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include <Sound.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Form1", 269, 245, 286, 300)
    $MenuItem1 = GUICtrlCreateMenu("Datei")
    $MenuItem4 = GUICtrlCreateMenuItem("Öffnen", $MenuItem1)
    $MenuItem3 = GUICtrlCreateMenuItem("", $MenuItem1)
    $MenuItem2 = GUICtrlCreateMenuItem("Beenden", $MenuItem1)
    $Button1 = GUICtrlCreateButton("Play", 8, 168, 43, 41, $WS_GROUP)
    $Button2 = GUICtrlCreateButton("Pause", 56, 168, 43, 41, $WS_GROUP)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

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

    Dim $var=false

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

    While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
    Case $GUI_EVENT_CLOSE
    Exit
    Case $MenuItem4
    $Data=FileOpenDialog("Datei","","Datei (*.mp3)")

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

    Case $MenuItem2
    Exit
    Case $Button1
    $SoundPlay=_SoundOpen($Data,"Notify") ; Datei öffnen
    $mij = _SoundPlay($SoundPlay,0) ; Datei abspielen
    $pos1 = _SoundLength($mij, 2) ; Länger der Spielzeit
    sleep($pos1) ; sleep über die Länge der Spielzeit
    _SoundStop($mij) ; Datei STOP

    ;_SoundClose($SoundPlay)
    Case $Button2
    _SoundPause($SoundPlay)

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

    EndSwitch
    WEnd

    [/autoit]

    Lieben Gruß,
    Alina

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Geheime Information: ;)
    k3mrwmIBHejryPvylQSFieDF5f3VOnk6iLAVBGVhKQegrFuWr3iraNIblLweSW4WgqI0SrRbS7U5jI3sn50R4a15Cthu1bEr