Jump to content

Recommended Posts

Posted

#include <GUIConstants.au3>

GUICreate("Hello World", 200, 100)

GUICtrlCreateLabel("Music", 60, 8)

GUISetState(@SW_SHOW)

SoundPlay("D:\Music\Song.mp3",0)

Sleep(100000)

This is my first script. Been reading the tuts so you'll recognise it. How do I keep the script open during the song? Without having some obsurd Sleep?

Posted

The flag on the SoundPlay() function should be holding your script up until the sound finishes, maybe jsut put a:

While 1

WEnd

at the end of your script.

Posted

I knew that, but it stops you from closing the program. So you have to listen to the whole sound. The song is about 5mins and if I want to cancel it then... Ctrl+alt+del ftl.

Posted

[optional] This flag determines if the script should wait for the sound to finish before continuing:

1 = wait until sound has finished

0 = continue script while sound is playing (default)

If 1 is there, nothing else in the script will happen because its paused.

If 0 is there, I have to put in a crazy sleep time to stop it quitting 10 seconds into the song.

Posted

#include <Sound.au3>
$Sound="path to sound"
$Length=_SoundLength($Sound,2)
_SoundPlay($Sound,0)
Sleep($Length)

:)

Posted

Nahuels worked =]. But im still not happy with using Sleep.. Weaponx yours did what i said it would do. Played song, then froze. Throughout the song. Had to ctrl+alt+del again -.-.

Posted

You want to play a song in the background? and then have the script exit after its done playing?

Well the one I posted does that. And you can quit by right-clicking the tray icon.... So I don't know.. :)

Posted

When I use the one with (the fish avatar forgot his name) it works fine. But doesn't the sleep thing screw up any other code I want to work? Such as after i play the song, I want to click buttons in the program. Won't it stop me from doing ti until the sleep is finished?

Basic outline:

Open program:

Music plays:

Do stuff in program:

Close whenever you want:

Posted (edited)

When I use the one with (the fish avatar forgot his name) it works fine. But doesn't the sleep thing screw up any other code I want to work? Such as after i play the song, I want to click buttons in the program. Won't it stop me from doing ti until the sleep is finished?

Use this then.. should do what you want.

#include <Sound.au3>
$Sound = "path to sound"
$Length = _SoundLength($Sound, 2)
_SoundPlay($Sound, 0)
$timer = TimerInit
While 1
    Sleep(10)
    If TimerDiff($timer) > $Length Then ExitLoop
        ;Do all your stuff here
WEnd
-edit-

wait.. if you want to do something else after, not while playing the song... then there's no problem using sleep() :)

Edited by Nahuel

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
×
×
  • Create New...