Jump to content

Stop song


Recommended Posts

  • Developers

Hi,

Is there some function I can stop song playing with SoundPlay :D ? I need it for Talk2Me (look at signature).

i542

SoundPlay("")

:wacko:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Hi,

I think Helge did a sound udf with some more funcs.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

Is there some function I can stop song playing with SoundPlay :D ? I need it for Talk2Me (look at signature).

i542

Hi i542

The method I use, is to have another script called from the first one, and which is the actuall player and is hidden. You can then use the Winkill command from your first script to stop the 2nd one. You pass command-line parameters to the 2nd script, that tells it where & what to play.

The following code is extracted from one of my programs, so you need to add your own changes.

' code in first script - AudioPlayer.exe
        Case $msg = $Button_P
            ; PLAY SELECTED TRACK
            PlaySelectedTrack()
        Case $msg = $Button_St
            ; STOP PLAYING SELECTED TRACK
            WinKill("Player")
            GUICtrlSetData($Label_d, "Track " & $num & "   00:00")
            $begin = ""
        Case $msg = $Button_rgt
            ; PLAY NEXT TRACK
            $num = $num + 1
            GUICtrlSetState($List_1, $GUI_FOCUS)
            Send("{DOWN}")
            PlayAnotherTrack()
        Case $msg = $Button_lft
            ; PLAY PREVIOUS TRACK
            $num = $num - 1
            GUICtrlSetState($List_1, $GUI_FOCUS)
            Send("{UP}")
            PlayAnotherTrack()

Func PlaySelectedTrack()
    If $num > 0 Then
        $song = $fold & $pth
        $sng = '"' & $song & '"'
        If FileExists($song) = 1 Then
            $begin = TimerInit()
            Run(@ScriptDir & "\Player.exe " & $sng)
        Else
            MsgBox(16, "Path Error", "Cannot find the track you wish to play!)
        EndIf
    EndIf
EndFunc

Func PlayAnotherTrack()
    WinKill("Player")
    $begin = ""
    $tot = IniRead($m3uini, "Total Of Tracks", "num", "")
    If $num = 0 Then
        $num = 1
    ElseIf $num > $tot Then
        $num = $tot
    EndIf
    GUICtrlSetData($Label_d, "Track " & $num & "   00:00")
    PlaySelectedTrack()
EndFunc

' code in second script - Player.exe
#include <GuiConstants.au3>

#NoTrayIcon

Dim $st

;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$Player = GuiCreate("Player", 151, 110,(@DesktopWidth-151)/2, (@DesktopHeight-110)/2 , $WS_OVERLAPPEDWINDOW + $WS_CLIPSIBLINGS)

If WinExists("AudioPlayer") <> 1 Then Exit

GuiSetState(@SW_HIDE, $Player)
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
    EndSelect
    If $st = "" Then
        $st = 1
        If $CmdLine[0] <> 0 Then
            $cmdln = $CmdLine[1]
            SoundPlay($cmdln, 1)
            ExitLoop
        EndIf
    EndIf
WEnd
Exit

Please note that the code in the second script is complete, while the first script is incomplete and needs to be modified to suit your script. Don't forget to add WinKill to the exit command of your first script, or you could be left with the second script playing, until the song/s finish - but task manager can kill the process of course.

The timer is only there if you are going to implement a visual time display (incomplete of course).

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • Developers

Hi i542

The method I use, is to have another script called from the first one, and which is the actuall player and is hidden. You can then use the Winkill command from your first script to stop the 2nd one. You pass command-line parameters to the 2nd script, that tells it where & what to play.

The following code is extracted from one of my programs, so you need to add your own changes.

-snip-

Please note that the code in the second script is complete, while the first script is incomplete and needs to be modified to suit your script. Don't forget to add WinKill to the exit command of your first script, or you could be left with the second script playing, until the song/s finish - but task manager can kill the process of course.

The timer is only there if you are going to implement a visual time display (incomplete of course).

Could you explain why to use this approach when you can just start it with SoundPlay("filename", 0) ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Simply LOVE such moments, when you find out that what you've been doing can be done in 4- lines!!! :D

Edit: speaking out of experience

Edited by marfdaman

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

Could you explain why to use this approach when you can just start it with SoundPlay("filename", 0) ?

Hi JdeB

I got this from an old script of mine, and would possibly do it differently now!

That said, I remember doing as you and others said, and had trouble getting it to work at the time ... something to do with trying to interrupt a loop ... if my memory serves me. My original program, was an mp3 playing one, with a full time readout, and various track abilities - using sleep for what I had in mind was just not feasible - I seem to recall.

Anyway, what I'm offering is an alternative - in case i542 has the same problems I did.

Always open to better ideas though!

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • Developers

Hi JdeB

I got this from an old script of mine, and would possibly do it differently now!

That said, I remember doing as you and others said, and had trouble getting it to work at the time ... something to do with trying to interrupt a loop ... if my memory serves me. My original program, was an mp3 playing one, with a full time readout, and various track abilities - using sleep for what I had in mind was just not feasible - I seem to recall.

Anyway, what I'm offering is an alternative - in case i542 has the same problems I did.

Always open to better ideas though!

No sure I understand what your issue is you have solved. Maybe you can give an example to shows the issue you mean so we can have a look at it?

Understand you are giving another option, but it's in my mind not the right approach to solve the OP's issue to shell another task when theres no real need. just makes things more complicated.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

No sure I understand what your issue is you have solved. Maybe you can give an example to shows the issue you mean so we can have a look at it?

Understand you are giving another option, but it's in my mind not the right approach to solve the OP's issue to shell another task when theres no real need. just makes things more complicated.

I understand your concerns, and would normally say the same myself.

I had no intention to go back and look too deeply into an old script, I was aware I had a problem in the past with the command - in the days before I got involved in the forum. I knew that if your suggestion worked for i542 then he would probably not even consider looking at mine - but just in case not, I added my solution. My solution is undoubtedly flawed, and my programming skill has come on in leaps and bounds since then, so I would probably not have the same issues with the loop aspect that I had way back when. The script I wrote, did many other things in relation to mp3's, m3u's, etc and I haven't released it yet ... though I'm working on it (just not at the moment). Before I release it, I'll inevitable update it ... at that time I'll probably find that I no longer need to do things the way I did then ... so it will never see the light of day as it was (except for some in this post).

When I get a chance I may test what is just relevant to this post ... but I can't promise when that will be ... sorry!

Actually, the sound playing aspect of my program, was only by way of checking paths (relative, etc), and was not a major element of the program itself ... so it may be relatively simple to check ... I'll get back to you when I can?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Hi JdeB

I've now had a chance to play with my old script, and can only presume that because the help file doesn't list a method to stop play, it never probably occurred to me to use SoundPlay("") at that point in my learning ... it all seems pretty silly now ... and so simple.

Is it possible that the command had a bug at that time, or has changed ... it seems a pretty simple thing to overlook ... I still can't believe I wouldn't have tried that, rather than go to all the effort I did ... somebody probably could have saved me a lot of foolish trouble & my silly post.

Maybe someone should update the help file, so post space isn't wasted on such simple things?

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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