Jump to content

Next Song Playlist


Recommended Posts

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

#NoTrayIcon
#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)
GUICtrlSetData($Slider,100)
GUICtrlSetLimit ($Slider,100,0)
$Label_8 = GuiCtrlCreateLabel("Thatsgreat2345", 10, 50, 80, 20)
GUICtrlSetColor(-1,0xff0000)
GUICtrlSetResizing (-1,$GUI_DOCKLEFT)
GuiSetState()
;---------------------------------------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
    sleep(100)
wend
endfunc
;-------------start--------------------
Do
    
  $msg = GUIGetMsg ()
   Select
     ;------------------ STOP MUSIC-------------
   Case   $msg = $stop
       soundplay("C:\exit.mp3")
     ;---------------END STOP MUSIC---------
;--------- PLAY MUSIC ---------
Case $msg = $play
$line = FileReadLine(@ProgramFilesDir & "\Thatsgreat2345\Playlist.ini", 1)
    Soundplay ($line)
;---------END PLAY MUSIC------
    
;--------------------------mute---------------
Case $msg = $Mute
    send("{VOLUME_MUTE}")
;-----------END MUTE--------------
;------------------volume----------------
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
        GUICtrlSetData($list,"")
        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)
        soundplay($line)
;---------------END PREVIOUS SONG-----------------------
;----------------- EXIT-----------------------
      Case $msg = $exit
         exit
   EndSelect
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...
Link to comment
Share on other sites

  • Moderators

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.

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...