Queener Posted November 1, 2013 Share Posted November 1, 2013 Is it possible to assign sound onto button and play music on background without having to open the mp3 via media player? Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 1, 2013 Moderators Share Posted November 1, 2013 asianqueen,Look at the Sound UDF - it allows you to play mp3s directly within AutoIt. I am listening to my background player as I type. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Queener Posted November 1, 2013 Author Share Posted November 1, 2013 (edited) works, but the form froze. I'm creating a survey form and while user is doing the survey; the music plays. The form windows just keep cycling with the background music on. Any click will make it none responses and end up closing it. [EDIT] nevermind... got it... _SoundPlay($sound, 1).... I just remove the 1 and it stops that cycling. Edited November 1, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 1, 2013 Moderators Share Posted November 1, 2013 (edited) asianqueen,And I am supposed to suggest a solution based just on that description? If you post the code you are using I will look at it for you and see what I can come up with. M23Edit: I see our posts crossed. Glad you got it sorted. Edited November 1, 2013 by Melba23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Queener Posted November 2, 2013 Author Share Posted November 2, 2013 Now for the loop; I tried If _SoundStop($sound) Then _SoundPlay($sound) EndIf But it doesn't work... I even tried if true statement, but still doesn't loop. Any idea? Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2013 Moderators Share Posted November 2, 2013 asianqueen,Check if the current file has ended - if so then restart it: If _SoundStatus($sound) = "stopped" Then _SoundPlay($sound) EndIfM23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Queener Posted November 2, 2013 Author Share Posted November 2, 2013 Can you confirm it's working? Cause that didn't work on me. I created a label to see if the text did have the following text and it did. As soon as the text change from playing to stopped, it changed to playing again, but no sound. $sound = _SoundOpen("bk.mp3") $Status = _SoundStatus($sound) $Label1 = GUICtrlCreateLabel($Status,40,30,50,15,-1,-1) If $Label1 = "stopped" Then _SoundPlay($sound) EndIf Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
BrewManNH Posted November 2, 2013 Share Posted November 2, 2013 You've been doing this long enough to know that you can't read the contents of a control the way you're doing it. $Label1 is never going to contain the word stopped, it will only contain the control ID of the label control. If you want to monitor the _SoundStatus, why are you looking at the label and not using the $Status variable, which quite clearly contains the text in your label? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2013 Moderators Share Posted November 2, 2013 asianqueen,Why is there a label in ther? You do it like this: #include <Sound.au3> HotKeySet("{ESC}", "On_Exit") $aSnd_ID = _SoundOpen("M:\Downloads\Tardis takeoff.mp3") _SoundPlay($aSnd_ID) While 1 If _SoundStatus($aSnd_ID) = "stopped" Then _SoundPlay($aSnd_ID) EndIf Sleep(10) WEnd Func On_Exit() _SoundStop($aSnd_ID) Exit EndFuncM23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Queener Posted November 3, 2013 Author Share Posted November 3, 2013 (edited) It still doesn't loop with the code you given. It plays and when the song ends; thats it. The reason I'm using a label is because I wanted to see if it actually display playing or stopped which it does display playing or stopped. So I use the command to play the song again if the label = stopped. Which that didn't help either. Done. EDIT: (I have to add a stop then play again to make it work.) #include <Sound.au3> HotKeySet("{ESC}", "On_Exit") $aSnd_ID = _SoundOpen("bk.mp3") _SoundPlay($aSnd_ID) while 1 sleep(1) if _SoundStatus($aSnd_ID) = "stopped" Then _SoundStop($aSnd_ID) _SoundPlay($aSnd_ID) EndIf sleep(10) WEnd Func On_Exit() _SoundStop($aSnd_ID) Exit EndFunc Edited November 3, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2013 Moderators Share Posted November 3, 2013 asianqueen, It still doesn't loop with the code you givenObviously it does for me when I use one of my mp3 files or I would not have posted it. Can you post the mp3 file you are trying to play (send it by PM if you would prefer). Perhaps there is something funny about that. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2013 Moderators Share Posted November 3, 2013 asianqueen,That is a most peculiar mp3 - it will not restart until it has been closed and reopened like this: #include <Sound.au3> HotKeySet("{ESC}", "On_Exit") $aSnd_ID = _SoundOpen("M:\Downloads\bk.mp3") _SoundPlay($aSnd_ID) While 1 If _SoundStatus($aSnd_ID) = "stopped" Then _SoundStop($aSnd_ID) _SoundOpen("M:\Downloads\bk.mp3") _SoundPlay($aSnd_ID) EndIf Sleep(10) WEnd Func On_Exit() _SoundStop($aSnd_ID) Exit EndFuncI will look inside it later and see if I can work out why it does this. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Queener Posted November 3, 2013 Author Share Posted November 3, 2013 yeah I scratch my head why it's not looping until it comes in mind that I tried to stop the play then play it again. It's a good catch =) Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 3, 2013 Moderators Share Posted November 3, 2013 asianqueen,I recoded the mp3 and it works fine now - there must be some encoding glitch in the file you are using. If I find the time I will have a deeper look inside the original and let you know if I find anything. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now