Jump to content

Soundplay()


will88
 Share

Recommended Posts

I made a gui and a button, when I click the button it has you select the file that you want to soundplay()

I need it to wait until the soundplay() is over before it continues,

Ive tried soundplay("whatever", 1) but it does soundplay() and pauses the whole script so I can't click anything else on the Gui while its playing that song

$song = FileOpenDialog("Title","","(*.*)")
iniwrite(@ScriptDIr & "\myini.ini", "Section", "CurrentSong",$song)
soundplay($song)
iniwrite(@ScriptDIr & "\myini.ini", "Section", "CurrentSong",""); clears current song(because its not playing)
iniwrite(@ScriptDIr & "\myini.ini", "Section", "PreviousSong",$song);makes it the previous song

reason I need it to wait in that part is because if the 'previous song' button is clicked it will always be the current song that it will play. So it won't work to go back a song if I click the button.

anyone have an idea of what I can do to make this work?

Edited by will88
Link to comment
Share on other sites

I made a gui and a button, when I click the button it has you select the file that you want to soundplay()

I need it to wait until the soundplay() is over before it continues,

Ive tried soundplay("whatever", 1) but it does soundplay() and pauses the whole script so I can't click anything else on the Gui while its playing that song

$song = FileOpenDialog("Title","","(*.*)")
iniwrite(@ScriptDIr & "\myini.ini", "Section", "CurrentSong",$song)
soundplay($song)
iniwrite(@ScriptDIr & "\myini.ini", "Section", "CurrentSong",""); clears current song(because its not playing)
iniwrite(@ScriptDIr & "\myini.ini", "Section", "PreviousSong",$song);makes it the previous song

reason I need it to wait in that part is because if the 'previous song' button is clicked it will always be the current song that it will play. So it won't work to go back a song if I click the button.

anyone have an idea of what I can do to make this work?

If I remember right, there's a sound udf that would allow you to get the length of a sound file...then you could set a timer, and once enough time passed that the song is now over, activate the "previous song" button...is that what you mean?
"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

  • Moderators

Good morning,

The UDF is Sound.au3 and is to be found in the "Include" folder of the AutoIt installation. It lets you control the sound files much more comprehensively than SoundPlay. Look in the Helpfile just under SoundPlay for the "_Sound....." commands. I have a background mp3 player running on my machine at the moment which uses this UDF to do practically everything you could ever want.

And if you want to be really up-to-date, RazerM has just released a new beta version, which you can find here:

http://www.autoitscript.com/forum/index.ph...45&start=45

This new version was developed (with a little help from me) to give the correct duration of VBR mp3s and more testing is always welcome.

Your 'play the previous track rather than replay the current' command is something I was thinking about adding to my player. I was looking at the same logic as you, but I intended to keep the current/previous track names as internal variables - only using a single IniWrite function when the player closes. I already IniWrite the name and position of the current file (among other things) on exit so that the player can resume the track on opening - adding another key for the previous track is just a question of adding a line.

Good luck, and please ask again if you need any assistance with Sound.au3.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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