[AutoIt]Simple media player 11-14-2011, 10:35 PM
#1
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
EndIfPierce the life fibers with your drill.




![[+]](https://sinister.li/images/modern/collapse_collapsed.png)
