Sinisterly
[AutoIt]Simple media player - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: [AutoIt]Simple media player (/Thread-AutoIt-Simple-media-player)



[AutoIt]Simple media player - 1234hotmaster - 11-14-2011

Code:
#include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <Sound.au3> ;by 1234hotmaster Global $Fpath = FileOpenDialog("Select Audio file",@WorkingDir,"Sound Files(*.mp3;*.wav)|All Files(*.*)") Global $Playing = False Global $SoundHwnd If Not @error Then $SoundHwnd = _SoundOpen($Fpath) If Not @error Then $MPlayer = GUICreate("Music Player Sample", 243,40, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_SIZEBOX,$WS_THICKFRAME), BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE)) GUISetBkColor(0x000000) $BACK = GUICtrlCreateButton("<<", 44, 8, 35, 25, BitOR($BS_FLAT,$WS_BORDER)) $STOP = GUICtrlCreateButton("[¯]", 84, 8, 35, 25, BitOR($BS_FLAT,$WS_BORDER)) GUICtrlSetFont(-1, 8, 400, 4, "Arial") $PLAYORPAUSE = GUICtrlCreateButton("l>", 124, 8, 35, 25, BitOR($BS_FLAT,$WS_BORDER)) GUICtrlSetFont(-1, 8, 400, 0, "Arial") GUICtrlSetTip(-1, "By 1234hotmaster") $FORWARD = GUICtrlCreateButton(">>", 164, 8, 35, 25, BitOR($BS_FLAT,$WS_BORDER)) GUISetState(@SW_SHOW) _SoundPlay($SoundHwnd) $Playing = True GUICtrlSetData($PLAYORPAUSE,"||") While 1 Switch GUIGetMsg() Case -3 _SoundClose($SoundHwnd) Exit Case $PLAYORPAUSE If Not $Playing Then _SoundPlay($SoundHwnd) GUICtrlSetData($PLAYORPAUSE,"||") $Playing = True ElseIf $Playing Then _SoundPause($SoundHwnd) GUICtrlSetData($PLAYORPAUSE,"l>") $Playing = False EndIf Case $BACK If $Playing Then $HMS = StringSplit(_SoundPos($SoundHwnd,1),":") If IsArray($HMS) Then _SoundPause($SoundHwnd) _SoundSeek($SoundHwnd,$HMS[1],$HMS[2],$HMS[3]-10) _SoundPlay($SoundHwnd) EndIf EndIf Case $FORWARD If $Playing Then $HMS = StringSplit(_SoundPos($SoundHwnd,1),":") If IsArray($HMS) Then _SoundPause($SoundHwnd) _SoundSeek($SoundHwnd,$HMS[1],$HMS[2],$HMS[3]+10) _SoundPlay($SoundHwnd) EndIf EndIf Case $STOP GUICtrlSetData($PLAYORPAUSE,"l>") _SoundStop($SoundHwnd) EndSwitch WinSetTitle(WinGetHandle($MPlayer),"Music Player Sample",_SoundPos($SoundHwnd,1) & " / " & _SoundLength($SoundHwnd,1)) If _SoundPos($SoundHwnd,1) >= _SoundLength($SoundHwnd,1) Then Sleep(500) _SoundPlay($SoundHwnd) EndIf WEnd EndIf



RE: [AutoIt]Simple media player - ReaperX - 11-14-2011

Nice. I Need Some Help. I Know How to use FileOpenDialog but If i Wanted to Make a Text Editor, How Would i Get the Text from a Text File to Open in $var = GUICtrlCreateEdit(...)? Would i Have to Grab data from the Control Using GUICtrlRead($var)?


RE: [AutoIt]Simple media player - 1234hotmaster - 11-15-2011

Code:
FileRead("C:\example.txt")

You mean like this? Smile

Edit: If there is any other question please post a thread Thank You.


RE: [AutoIt]Simple media player - gunjal_nikhil - 04-01-2012

good post pl keep posting nice tricks