Jump to content

Only me.. Again :P


sTYLE
 Share

Recommended Posts

Okay so now I've figured out the sound I thought I'd add buttons. So the start button works perfectly

Func button5()
   $msg=$button5= SoundPlay(@WindowsDir & "LibrariesMusicahh.wav") EndFunc

But the Stop button doesn't work. I tried both _SoundStop and SoundStop. Are they both wrong or have i gone wrong?

$button4=GUICtrlCreateButton("Stop Music",184,100,85,40)
$button5=GUICtrlCreateButton("Start Music",184,60,85,40)


Func button4()
$msg=$button4= SoundStop(@WindowsDir & "LibrariesMusicahh.wav")
   EndFunc

If $msg=$button4 Then button4()
   If $msg=$button5 Then button5()

The error is:

$msg=$button4= SoundStop(@WindowsDir & "LibrariesMusicahh.wav")
$msg=$button4= ^ ERROR
Edited by sTYLE
Link to comment
Share on other sites

  • Moderators

Hi, STYLE. Look at the helpfile under SoundPlay(), it gives you an example of how to stop the current sound with another call to SoundPlay.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Did you look at the examples then? It's not confusing if you just read. Also please use a meaningful title next time you create a thread.

Yes, It's confusing, all's I need is the stop sound code, whatever it is.
Link to comment
Share on other sites

Hi, STYLE. Look at the helpfile under SoundPlay(), it gives you an example of how to stop the current sound with another call to SoundPlay.

_SoundClose($aSound) This? So I'm guessing ($aSound) means your directory to the sound? e.g. @WindowsDir & "LibrariesMusicahh.wav"

if so.. That didn't work.

Link to comment
Share on other sites

Did you run the helpfile example as AdmiralWhiteHatAlkex suggested? I've simplified it a bit for you.

#include <Sound.au3>

;open sound file : must be modified if run under Vista
$sound = _SoundOpen(@WindowsDir & "mediaWindows XP Startup.wav") ; replace with an existing sound file if necessary
If @error Then Exit ; In case the file doesn't exist or other issues opening the file

_SoundPlay($sound)
While 1
    Sleep(100)
    If _SoundPos($sound, 2) >= 1000 Then ; After 1 second stop the sound
        _SoundStop($sound)
        ExitLoop
    EndIf
WEnd

_SoundClose($sound)

I doubt this simple script will work on vista. I haven't read enough about it. I still have XP.

Edited by czardas
Link to comment
Share on other sites

  • Moderators

The helpfile states, use SoundPlay("") to stop a playing sound and close the open handle.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • Moderators

sTYLE,

You are confusing the native AutoIt function SoundPlay and the functions within the Sound.au3 UDF which all begin with an underscore like this _Sound*. As is often the case in AutoIt you cannot mix them. ;)

If you used SoundPlay to start playing the file then you need to do as JLogan3o13 sugested and reuse SoundPlay to stop it. If you want to use the more comprehensive range of functions from the Sound UDF then czardas has shown you how. ;)

And as to the Helpfile being confusing - do you realise how lucky you are to have such a comprehensive aid to learning AutoIt? It is without doubt the best Help file I have ever seen and is constantly being improved thanks to the community and its editors (particulariy guinness). You just need to take the time to read it carefully and look at the examples. :)

M23

Edit: And the Admiral has a valid point about the thread title - please use sensible titles in future or you may find the thread being locked. :)

Edited by Melba23
Fingerwagging

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