Jump to content

Music Player v2.0


AlmarM
 Share

Recommended Posts

I made this Music Player :P

#include <GUIConstants.au3>
#include <Sound.au3>

DIM $Read

$GUI = GUICreate("Music Player v2.0", 270, 70, -1, -1)
$Input_1 = GUICtrlCreateInput("", 10, 10, 220, 20)
$Button_1 = GUICtrlCreateButton("...", 240, 10, 20, 20)
$Button_2 = GUICtrlCreateButton("Play", 10, 35, 80)
$Button_3 = GUICtrlCreateButton("Pause", 95, 35, 80)
$Button_4 = GUICtrlCreateButton("Stop", 180, 35, 80)
GUICtrlSetState($Button_2, $GUI_DISABLE)
GUICtrlSetState($Button_3, $GUI_DISABLE)
GUICtrlSetState($BUtton_4, $GUI_DISABLE)

GUISetState()
While 1
    $nMsg = GUIGetMsg()
    Select
    Case $nMsg = $GUI_EVENT_CLOSE
        Exit
    Case $nMsg = $Button_1
        $Opened_File = FileOpenDialog("Open Music File", "", "All Music Files (*.wav;*.avi;*.mp3)|All Files (*.*)",12)
        GUICtrlSetData($Input_1, $Opened_File)
        GUICtrlSetState($Button_2, $GUI_ENABLE)
    Case $nMsg = $Button_2
        $Read = GUICtrlRead($Input_1)
        $Play = _SoundPlay($Read)
        GUICtrlSetState($Button_3, $GUI_ENABLE)
        GUICtrlSetState($Button_4, $GUI_ENABLE)
    Case $nMsg = $Button_3
        _SoundPause($Read)
    Case $nMsg = $Button_4
        GUICtrlSetState($Button_3, $GUI_DISABLE)
        _SoundStop($Read)
    EndSelect
WEnd

Mayby someone can use the idea ;)

Edited by AlmarM

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

Check this out AMP 3

And lol your thread is 'Music Player v2.0' but

$GUI = GUICreate("Music Player v1.0", 270, 70, -1, -1)
Lol forgot that :P

Minesweeper

A minesweeper game created in autoit, source available.

_Mouse_UDF

An UDF for registering functions to mouse events, made in pure autoit.

2D Hitbox Editor

A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.

Link to comment
Share on other sites

If he asked for something that he need, i'd be glad to send him some of the code, or help him develop an idea on how to go about it, can't make it open soucre because a buddy wrote the library functions and insits that it not be open soucre, his user name is like HumanInterfaceProject or something, its on the amp 3 thread

[center][/center]

Link to comment
Share on other sites

If he asked for something that he need, i'd be glad to send him some of the code, or help him develop an idea on how to go about it, can't make it open soucre because a buddy wrote the library functions and insits that it not be open soucre, his user name is like HumanInterfaceProject or something, its on the amp 3 thread

I do understand the situation you are in, but it was funny when you linked an application and "Check this out" when it has no source available.

On to topic:

I like the way this can play many music at the same time lol, maybe some great remix will come out of it.

Link to comment
Share on other sites

You should make it so that you could load a bunch of songs into a listview and control volume on each one and play/pause it and, also, have an option where to play the file, you just click on it in the listview. You could use it like a DJ mixer, or create your own music with it, or play sound FX... that could be really cool!

Link to comment
Share on other sites

And you could also assign each sound a key, so that you just had to press the key to select or play it!

Link to comment
Share on other sites

  • 5 months later...
  • 4 years later...

Just wrote another one:

#Region Includes
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <Sound.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#EndRegion Includes
#Region Options
Opt("GUIOnEventMode", 1)
If @Compiled Then
AutoItSetOption("TrayIconHide",1)
Else
Opt("TrayIconDebug", 1)
EndIf
#EndRegion Options
#Region Global variables
Global $currentFile = ""
Global $track = ""
#EndRegion Global variables
#Region ### START Koda GUI section ###
$frmMain = GUICreate("Au3Player2", 241, 142, 775, 554)
$frmMainBtnPlay = GUICtrlCreateButton("Play", 96, 88, 51, 25)
$frmMainBtnStop = GUICtrlCreateButton("Stop", 152, 88, 35, 25)
$frmMainLblTime = GUICtrlCreateLabel("00:00:00/00:00:00", 8, 32, 191, 33)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$frmMainBtnOpen = GUICtrlCreateButton("Open", 16, 88, 35, 25)
$frmMainPrgPosition = GUICtrlCreateProgress(8, 64, 190, 9)
$frmMainSldVolume = GUICtrlCreateSlider(200, 0, 38, 85, BitOR($GUI_SS_DEFAULT_SLIDER,$TBS_VERT,$TBS_TOP,$TBS_LEFT))
$frmMainLblFile = GUICtrlCreateLabel("", 8, 8, 190, 17)
$frmMainBtnRwd = GUICtrlCreateButton("Rwd", 56, 88, 35, 25)
$frmMainBtnFwd = GUICtrlCreateButton("Fwd", 192, 88, 35, 25)
$frmMainLblAuthor = GUICtrlCreateLabel("Au3Player2 written by C!$C0^211", 40, 120, 162, 17)
#EndRegion ### END Koda GUI section ###
#Region Bind events
GUISetOnEvent($GUI_EVENT_CLOSE, "evtExit",$frmMain)
GUICtrlSetOnEvent($frmMainBtnOpen, "evtOpen")
GUICtrlSetOnEvent($frmMainBtnPlay, "evtPlay")
GUICtrlSetOnEvent($frmMainSldVolume, "evtVolume")
GUICtrlSetOnEvent($frmMainBtnStop, "evtStop")
GUICtrlSetOnEvent($frmMainBtnFwd, "evtForward")
GUICtrlSetOnEvent($frmMainBtnRwd, "evtRewind")
#EndRegion Bind events
#Region Configure
GUICtrlSetState($frmMainBtnStop,$GUI_DISABLE)
GUICtrlSetState($frmMainBtnPlay,$GUI_DISABLE)
GUICtrlSetState($frmMainBtnFwd,$GUI_DISABLE)
GUICtrlSetState($frmMainBtnRwd,$GUI_DISABLE)
SoundSetWaveVolume(100)
#EndRegion Configure
#Region Show main form
GUISetState(@SW_SHOW,$frmMain)
#EndRegion Show main form
#Region Window sleeper aka main loop
$timerLoop = 50
While 1
If $track <> "" Then
  If _SoundPos($track, 2) >= _SoundLength($track, 2) Then
   evtStop()
  EndIf
  $format = StringRight($currentFile,3)
  If $format <> "mp3" And $format <> "wav" Then
   GUICtrlSetData($frmMainLblTime,_SoundPos($track,2)&"/"&_SoundLength($track,2))
  Else
   GUICtrlSetData($frmMainLblTime,_SoundPos($track,1)&"/"&_SoundLength($track,1))
  EndIf
  GUICtrlSetData($frmMainPrgPosition,((_SoundPos($track,2)*100)/_SoundLength($track,2)))
EndIf
Sleep($timerLoop)
WEnd
#EndRegion Window sleeper aka main loop
#Region Exit event
Func evtExit()
Exit
EndFunc
#EndRegion Exit event
#Region Forward event
Func evtForward()
If $track <> "" Then
  $ticks = _SoundPos($track,2)
  $h = 0
  $i = 0
  $s = 0
  $ticks = $ticks + 1000
  If $ticks > _SoundLength($track,2) Then
   $ticks = _SoundLength($track,2)
  EndIf
  __SoundTicksToTime($ticks,$h,$i,$s)
  _SoundSeek($track,$h,$i,$s)
  _SoundPlay($track)
EndIf
EndFunc
#EndRegion Forward event
#Region Open event
Func evtOpen()
_SoundClose($track)
$track = ""
GUICtrlSetData($frmMainBtnPlay,"Play")
GUICtrlSetState($frmMainBtnPlay,$GUI_DISABLE)
$oldFile = $currentFile
$currentFile = FileOpenDialog("Open audio file...",@DesktopDir,"Audio (*.mid;*.mp3;*.wav)|All (*.*)",1)
If $currentFile = "" Then
  $currentFile = $oldFile
EndIf
If $currentFile = "" Then
  Return
EndIf
$track = _SoundOpen($currentFile)
If @error = 2 Then
  MsgBox(0, "Error", "The file does not exist")
  $track = ""
  $currentFile = ""
  Return
ElseIf @extended <> 0 Then
  $extended = @extended ;assign because @extended will be set after DllCall
  $stText = DllStructCreate("char[128]")
  $errorstring = DllCall("winmm.dll", "short", "mciGetErrorStringA", "str", $extended, "ptr", DllStructGetPtr($stText), "int", 128)
  MsgBox(0, "Error", "The open failed." & @CRLF & "Error Number: " & $extended & @CRLF & "Error Description: " & DllStructGetData($stText, 1) & @CRLF & "Please Note: The sound may still play correctly.")
  $track = ""
  $currentFile = ""
  Return
EndIf
GUICtrlSetState($frmMainBtnPlay,$GUI_ENABLE)
GUICtrlSetData($frmMainLblTime,_SoundPos($track,1)&"/"&_SoundLength($track,1))
GUICtrlSetData($frmMainLblFile,"..."&StringRight($currentFile,30))
GuiCtrlSetTip($frmMainLblFile,$currentFile,"Current track:")
EndFunc
#EndRegion Open event
#Region Play event
Func evtPlay()
If $currentFile = "" Then
  GUICtrlSetState($frmMainBtnPlay,$GUI_DISABLE)
  Return
EndiF
GUICtrlSetState($frmMainBtnOpen,$GUI_DISABLE)
GUICtrlSetState($frmMainBtnStop,$GUI_ENABLE)
GUICtrlSetState($frmMainBtnFwd,$GUI_ENABLE)
GUICtrlSetState($frmMainBtnRwd,$GUI_ENABLE)
If GUICtrlRead($frmMainBtnPlay) = "Pause" Then
  GUICtrlSetData($frmMainBtnPlay,"Resume")
 
  _SoundPause($track)
ElseIf GUICtrlRead($frmMainBtnPlay) = "Resume" Then
  GUICtrlSetData($frmMainBtnPlay,"Pause")
  _SoundResume($track)
Else
  GUICtrlSetData($frmMainBtnPlay,"Pause")
  _SoundPlay($track)
EndIf
EndFunc
#EndRegion Play event
#Region Rewind event
Func evtRewind()
If $track <> "" Then
  $ticks = _SoundPos($track,2)
  $h = 0
  $i = 0
  $s = 0
  $ticks = $ticks - 1000
  If $ticks < 0 Then
   $ticks = 0
  EndIf
  __SoundTicksToTime($ticks,$h,$i,$s)
  _SoundSeek($track,$h,$i,$s)
  _SoundPlay($track)
EndIf
EndFunc
#EndRegion Rewind event
#Region Stop event
Func evtStop()
_SoundStop($track)
GUICtrlSetData($frmMainBtnPlay,"Play")
GUICtrlSetState($frmMainBtnFwd,$GUI_DISABLE)
GUICtrlSetState($frmMainBtnRwd,$GUI_DISABLE)
GUICtrlSetState($frmMainBtnStop,$GUI_DISABLE)
GUICtrlSetState($frmMainBtnOpen,$GUI_ENABLE)
EndFunc
#EndRegion Stop event
#Region Volume event
Func evtVolume()
$volume = Int(GUICtrlRead($frmMainSldVolume))
$volume = Abs($volume - 100)
SoundSetWaveVolume($volume)
EndFunc
#EndRegion Volume event
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...