Jump to content
Sign in to follow this  
TheOnlyOne

music player

Recommended Posts

TheOnlyOne

hi my problem is when the program read what music numbers there is in the "playerlist" then it only play the last one?

my code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <file.au3>
#include <array.au3>
#Include <GuiListView.au3>
Opt("GUIDataSeparatorChar")
dim $szDrive, $szDir, $szFName, $szExt
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 447, 193, 125)
GUISetBkColor(0x004E98)
$Radio1 = GUICtrlCreateRadio("play", 416, 152, 113, 25)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
$Radio2 = GUICtrlCreateRadio("pause", 416, 192, 113, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
$Button1 = GUICtrlCreateButton("choose song", 56, 40, 89, 33, 0)
$edit=GUICtrlCreateedit("", 48, 112, 145, 241,0)
$Radio3 = GUICtrlCreateRadio("stop", 416, 224, 113, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
$Radio4 = GUICtrlCreateRadio("other", 416, 256, 113, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlSetCursor (-1, 0)
$Label1 = GUICtrlCreateLabel("Playlist", 56, 88, 44, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$Slider1 = GUICtrlCreateSlider(224, 376, 289, 25)
$Label2 = GUICtrlCreateLabel("Sound volume", 312, 352, 84, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Radio4
    
Case $Radio2
    
case $Radio1
    


    $2=GUICtrlRead ($edit,1)
    
    soundplay ($1)
case $radio3
    
case $Button1

$1=FileOpenDialog("find your music",@DesktopDir,"(*.*)",1,"")
$TestPath = _PathSplit($1, $szDrive, $szDir, $szFName, $szExt)
GUICtrlSetData ($edit,$szFName& @crlf,1)

EndSwitch
WEnd

thanks :D

Share this post


Link to post
Share on other sites
Skruge

hi my problem is when the program read what music numbers there is in the "playerlist" then it only play the last one?

soundplay ($1)
$1=FileOpenDialog("find your music",@DesktopDir,"(*.*)",1,"")
$1 always equals the last file that was selected after clicking "choose song".

You're assigning $2 to the contents of $edit, but you're not doing anything with it.

Suggestions:

Store the file paths in an array, since you'll need them later. (Unless you restrict playback to a single folder)

When "play" is pressed, loop through the array to play each file.

If you want to be able to select a single song, then a List would be better than an Edit.

Good luck!


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
TheOnlyOne

can you give some tips how i can do it to arrays ? i cant figure out how :S ?

Share this post


Link to post
Share on other sites
TheOnlyOne

okay now i tryed this

$1=FileOpenDialog("find your music",@DesktopDir,"(*.*)",1,"")
$TestPath = _PathSplit($1, $szDrive, $szDir, $szFName, $szExt)
GUICtrlSetData ($edit,$szFName& @crlf,1)
_ArrayAdd ($playlist,$1)

and

soundplay ($playlist)

cant get that to work?

why?

Share this post


Link to post
Share on other sites
Skruge

Assuming that you declared $playlist as an array, and that _ArrayAdd succeeded (Use _ArrayDisplay to verify), you can access the array elements like this:

For $i = 0 to Ubound($playlist) -1
       If FileExists($playlist[$i]) then SoundPlay($playlist[$i])
   Next


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
TheOnlyOne

okay just to be sure i declared here right ?

local $playlist[50]

and when i use _ArrayDisplay($playlist,"ss",10,0,"","")

then is only show the first file i set in ?

and when i try play it dosent work ?

Share this post


Link to post
Share on other sites
TheOnlyOne

bumb??

Share this post


Link to post
Share on other sites
Skruge

okay just to be sure i declared here right ?

local $playlist[50]

and when i use _ArrayDisplay($playlist,"ss",10,0,"","")

then is only show the first file i set in ?

and when i try play it dosent work ?

_ArrayAdd will automatically expand the array, so no need to make it so big.

You're limiting your _ArrayDisplay call to 10 records, so given your 50-element array declaration, I'm surprised you didn't get 10 empty records.

Anyway, this code works for me.

Be sure to set the wait flag on SoundPlay, or it'll skip to the last entry.

CODE
#include <ButtonConstants.au3>

#include <EditConstants.au3>

#include <GUIConstantsEx.au3>

#include <SliderConstants.au3>

#include <StaticConstants.au3>

#include <WindowsConstants.au3>

#include <file.au3>

#include <array.au3>

#include <GuiListView.au3>

Opt("GUIDataSeparatorChar")

Dim $szDrive, $szDir, $szFName, $szExt, $playlist[1]

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Form1", 633, 447, 193, 125)

GUISetBkColor(0x004E98)

$Radio1 = GUICtrlCreateRadio("play", 416, 152, 113, 25)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetCursor(-1, 0)

$Radio2 = GUICtrlCreateRadio("pause", 416, 192, 113, 17)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetCursor(-1, 0)

$Button1 = GUICtrlCreateButton("choose song", 56, 40, 89, 33, 0)

$edit = GUICtrlCreateEdit("", 48, 112, 145, 241, 0)

$Radio3 = GUICtrlCreateRadio("stop", 416, 224, 113, 17)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetCursor(-1, 0)

$Radio4 = GUICtrlCreateRadio("other", 416, 256, 113, 17)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUICtrlSetCursor(-1, 0)

$Label1 = GUICtrlCreateLabel("Playlist", 56, 88, 44, 17)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

$Slider1 = GUICtrlCreateSlider(224, 376, 289, 25)

$Label2 = GUICtrlCreateLabel("Sound volume", 312, 352, 84, 17)

GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $Radio4

Case $Radio2

Case $Radio1

For $i = 0 To UBound($playlist) - 1

If FileExists($playlist[$i]) Then SoundPlay($playlist[$i], 1)

Next

Case $Radio3

Case $Button1

$1 = FileOpenDialog("find your music", @DesktopDir, "(*.*)", 1, "")

$TestPath = _PathSplit($1, $szDrive, $szDir, $szFName, $szExt)

GUICtrlSetData($edit, $szFName & @CRLF, 1)

_ArrayAdd($playlist, $1)

EndSwitch

WEnd


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites
TheOnlyOne

okay nice it works now :D

but one thing its begin to lag when i click play

so the song is played but you cant click anyway in the gui without its being f***ed up :S ? how can i reduce the lag ?

Share this post


Link to post
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
Sign in to follow this  

×