Ady Posted April 11, 2008 Share Posted April 11, 2008 Hello all, I have a question. I made some sort of media player. It is very simple, but in all media players the play button changes into the pause button and pauses the muzic or media. I know how to change the text, but i dont know what script to write to pause the music. I tried a lot of if, do, while, select, assigments but nothing. The code form my media player is: CODE#include <Sound.au3> #include <GUIConstants.au3> GUICreate("Media Player",800,600,"","",$WS_MAXIMIZEBOX+$WS_MINIMIZEBOX) GUISetBkColor(0x00ffff) GUISetState() $stop = GUICtrlCreateButton("Stop",10,10,40,20) $play = GUICtrlCreateButton("Play",10,40,40,20) $open = GUICtrlCreateButton("Open",10,70,40,20) While 1 $message = GUIGetMsg() If $message = $GUI_EVENT_CLOSE Then ExitLoop Select Case $message = $open $music = FileOpenDialog("Open file",@DesktopDir,"Mp3 Files (*.mp3)") _SoundPlay($music) $pause = GUICtrlSetData($play,"Pause") Case $message = $stop _SoundStop($music) GUICtrlSetData($play,"Play") EndSelect WEnd Can you help me, please . What statement to write that the play button to play and pause the music file?? Link to comment Share on other sites More sharing options...
smashly Posted April 11, 2008 Share Posted April 11, 2008 Hi,expandcollapse popup#include <Sound.au3> #include <GUIConstants.au3> Global $mAlias GUICreate("Media Player",800,600,"","",$WS_MAXIMIZEBOX+$WS_MINIMIZEBOX) GUISetBkColor(0x00ffff) $stop = GUICtrlCreateButton("Stop",10,10,40,20) $play = GUICtrlCreateButton("Play",10,40,40,20) $open = GUICtrlCreateButton("Open",10,70,40,20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _SoundStop($mAlias) Exit Case $open Local $music = FileOpenDialog("Open file",@DesktopDir,"Mp3 Files (*.mp3)", 3) If Not @error Then _SoundStop($mAlias) $mAlias = _SoundOpen($music) _SoundPlay($mAlias) GUICtrlSetData($play, "Pause") Else $mAlias = "" EndIf Case $play If GUICtrlRead($play) = "Play" And $mAlias <> "" Then _SoundResume($mAlias) GUICtrlSetData($play, "Pause") ElseIf GUICtrlRead($play) = "Pause" And $mAlias <> "" Then _SoundPause($mAlias) GUICtrlSetData($play, "Play") EndIf Case $stop _SoundStop($mAlias) $mAlias = "" GUICtrlSetData($play, "Play") EndSwitch WEndCheers Link to comment Share on other sites More sharing options...
Ady Posted April 12, 2008 Author Share Posted April 12, 2008 Hi,expandcollapse popup#include <Sound.au3> #include <GUIConstants.au3> Global $mAlias GUICreate("Media Player",800,600,"","",$WS_MAXIMIZEBOX+$WS_MINIMIZEBOX) GUISetBkColor(0x00ffff) $stop = GUICtrlCreateButton("Stop",10,10,40,20) $play = GUICtrlCreateButton("Play",10,40,40,20) $open = GUICtrlCreateButton("Open",10,70,40,20) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _SoundStop($mAlias) Exit Case $open Local $music = FileOpenDialog("Open file",@DesktopDir,"Mp3 Files (*.mp3)", 3) If Not @error Then _SoundStop($mAlias) $mAlias = _SoundOpen($music) _SoundPlay($mAlias) GUICtrlSetData($play, "Pause") Else $mAlias = "" EndIf Case $play If GUICtrlRead($play) = "Play" And $mAlias <> "" Then _SoundResume($mAlias) GUICtrlSetData($play, "Pause") ElseIf GUICtrlRead($play) = "Pause" And $mAlias <> "" Then _SoundPause($mAlias) GUICtrlSetData($play, "Play") EndIf Case $stop _SoundStop($mAlias) $mAlias = "" GUICtrlSetData($play, "Play") EndSwitch WEndCheers Thank you very much!!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now