Page 1 of 1
Problem with wait command
Posted: Mon Jun 16, 2014 10:23 am
by pjfry
Hi there,
I try to build an player with looping, but the looping should wait a few seconds befor starting the song angain.
So I added a player to my card and put the folloing code in thi splayer element:
Code: Select all
on playerFinished
if the hilite of button chk_effects1 is true then
wait for 3 seconds
set the currentTime of player "player_effectsslot1" to zero
start player "player_effectsslot1"
else
end if
end playerFinished
Now the player repeats the songs but did not wait the given time of 3 seconds before repeating it. I use version 6.7 (DP 4)
Thanks for your help
Benny
Re: Problem with wait command
Posted: Mon Jun 16, 2014 12:16 pm
by Klaus
Hi Benny,
1. welcome to the forum!
2. Is this on the desktop or mobile platform?
3. "playerfinished" is mobile only!
4. If you do not have an ELSE case, no need to use ELSE
Code: Select all
...
if the hilite of button "chk_effects1" is true then
wait for 3 seconds
## ...
end if
...
5. ALWAYS use quotes around object names!
-> player "name of player"
Best
Klaus
Re: Problem with wait command
Posted: Mon Jun 16, 2014 4:26 pm
by pjfry
Hello Klaus,
thanks for your fast answer and your useful hints
1) I did a mistake ... I thought this was for desktop use also ... but after a short look into the dictionary I saw that this is only for mobile platform
So I have now no idea how to get my code working for desktop use.
How can a do a looping with a certain delay?
Greetings Benny
Re: Problem with wait command
Posted: Mon Jun 16, 2014 4:33 pm
by Klaus
Hi Benny,
on the desktop you can use the "playstopped" message of the player!
Put this into the players script:
Code: Select all
on playerStopped
## I ususally avoid (more or less) long IF THEN END IFs ;-)
if the hilite of button "chk_effects1" = FALSE then
exit to top
end if
wait 3 secs
set the currentTime of player "player_effectsslot1" to 0
start player "player_effectslot1"
end playerStopped
Best
Klaus
Re: Problem with wait command
Posted: Mon Jun 16, 2014 7:51 pm
by Simon
Hi Benny,
If you are new to liveCode you should not be using a dp version. go here:
http://downloads.livecode.com/livecode/
And get the latest "stable" release.
dp (Developer Preview) may have bugs and instability.
Simon
Re: Problem with wait command
Posted: Tue Jun 17, 2014 5:10 pm
by pjfry
Hi there,
@SImon
Thanks for this advice I now use the latest stable Version 6.6.2
@Klaus
Thanks for this code example. But is still do not work. I tried to debug it but I do not find any mistake.
If I set a Stop Point to debug at the on playerStopped I recognizes that the player stopped, i f I click at next step the code hilight the if condition and than an the next step jumps one line up and do not use the if condition. But I have no idea where the problem is.
Maybe you have another hint for me
EDIT:
Ok my mistake the correct message to wait for is
playStopped not playerStopped
Now everything works just fine
Thanks Benny
Re: Problem with wait command
Posted: Tue Jun 17, 2014 5:47 pm
by Klaus
Oh, yes, PLAYSTOPPED, my fault, sorry!
Glad you got it working!