Jump to content
Sign in to follow this  

Next Song Playlist

Recommended Posts


Answered... thanks

Edited by thatsgreat2345

Share this post

Link to post
Share on other sites

Im working on a playlist but im having trouble i want it so that if you click next then it plays the next song in the playlist and if u press previous then it plays the previous song but i dont know how to do that , i was thinking about having it to install 2 .ini one for the playlist and one for the song count, it would count the number of lines on playlist.ini and put the amount into the songcount.ini then it would get the location of the song playing and which ever line that the location was on the playlist.ini then it would say that it was playing like song 3 cuz it was on line 3 then that would tell the songlist to either + 1 or - 1 on the file readline of the playlist.ini just having a little trouble with that :P so if anyone could help that would be greatly appreciated

#include <GuiConstants.au3>
;--------------------------------------GUI START--------------------------------------------------------
GuiCreate("Music Player", 400, 400,(@DesktopWidth-309)/2, (@DesktopHeight-76)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
GUISetBkColor (0x000000)
$List = GuiCtrlCreateList("", 150, 220, 110, 175)
$Add = GuiCtrlCreateButton("Add", 60, 240, 60, 20)
GUICtrlSetLimit(-1,200); to limit horizontal scrolling
$Clear = GuiCtrlCreateButton("Clear", 60, 270, 60, 20)
$Play = GuiCtrlCreateButton("Play", 10, 10, 50, 20)
$Next = GuiCtrlCreateButton("Next", 70, 10, 50, 20)
$Mute = GuiCtrlCreateButton("Mute", 190, 10, 50, 20)
$stop = GuiCtrlCreateButton("Stop", 250, 10, 50, 20)
$exit = GuiCtrlCreateButton("Exit", 310, 10, 50, 20)
$previous = GuiCtrlCreateButton("Previous", 130, 10, 50, 20)
$slider = GUICtrlCreateSlider (150,50,100,40)
GUICtrlSetLimit ($Slider,100,0)
$Label_8 = GuiCtrlCreateLabel("Thatsgreat2345", 10, 50, 80, 20)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT)
;---------------------------------------GUI END---------------------------------------------------------
;----------------------------------DIM VARS-------------------------
Dim $play
Dim $Mute
dim $stop
Dim $exit
Dim $slider
DIm $msg
Dim $playlist
Dim $list
Dim $file
Dim $line
DIm $previous
;--------------DIM END
func stop()
    while 1
  $msg = GUIGetMsg ()
     ;------------------ STOP MUSIC-------------
   Case   $msg = $stop
     ;---------------END STOP MUSIC---------
;--------- PLAY MUSIC ---------
Case $msg = $play
$line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.ini", 1)
    Soundplay ($line)
;---------END PLAY MUSIC------
Case $msg = $Mute
;-----------END MUTE--------------
Case $msg = $slider
    SoundSetWaveVolume (GUICtrlRead($slider))
;-------------END VOLUME---------------
;-------------------ADD SONG---------------
Case $msg = $ADD
    $playlist=FileOpenDialog ("Choose music", "", "Musicfiles(*.mp3;*.wma;*.wav;*.wave;*.mid;*)")
    FileWrite(@ProgramFilesDir & "\Thatsgreat2345\Playlist.ini", $playlist & @CRLF)
    GUICtrlSetData($list, $playlist)
;-----------------END ADD SONG --------------------
;---------------------CLEAR SONG-------------------
case $msg = $clear
        FileDelete(@ProgramFilesDir & "\Thatsgreat2345\Playlist.ini")
        FileInstall("C:\Documents and Settings\NEON\Desktop\Playlist.ini", @ProgramFilesDir & "\Thatsgreat2345\Playlist.ini")
;---------------------- END CLEAR SONG--------------------
;----------------------NEXT SONG----------------
    Case $msg = $Next
        $line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.ini", 1 + 1)
    Soundplay ($line)
;------------------END NEXT SONG-----------------------
;-----------------PREVIOUS SONG--------------
    Case $msg = $previous
        $line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.ini", 2 - 1)
;---------------END PREVIOUS SONG-----------------------
;----------------- EXIT-----------------------
      Case $msg = $exit
Until $msg = $GUI_EVENT_CLOSE
;------------- END EXIT-----------------
an easier way to do this may be to read in the playlist to an array with FileReadToArray() then just have a placeholder variable. your previous and next buttons can increment or decrement that variable, and just have a condition in your loop for the gui that if the index of the song playing is diff than the placeholder, play the placeholder and update the now playing variable...

Share this post

Link to post
Share on other sites

I think this topic was answered here just for reference if someone looks at this again: http://www.autoitscript.com/forum/index.php?showtopic=19956

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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