Need a message that a player is finished
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Need a message that a player is finished
I am building an audio (and then a video) player into an app. I need the play/pause button to change back to play when the audio or video is at the end. Does the player send a message that it has reached the end?
Thanks,
Thanks,
Alex Adams
(a)2 Technology Parnters
alex@a2technology.com
www.a2technology.com
www.promisstudio.com
831-726-8013
(a)2 Technology Parnters
alex@a2technology.com
www.a2technology.com
www.promisstudio.com
831-726-8013
Hi Alex,
there is the "playstopped" message, but this will also get fired when the user stops the player.
But when using the "playstopped" message you could always check if the currenttime of the player = the duration of the player, so you know if the player has reached the end.
Know what I mean?
Best
Klaus
there is the "playstopped" message, but this will also get fired when the user stops the player.
But when using the "playstopped" message you could always check if the currenttime of the player = the duration of the player, so you know if the player has reached the end.
Know what I mean?
Best
Klaus
Thanks Klaus -- and one more question...
Klaus,
Thanks. I see that there is a playstarted and playpaused too. That's perfect.
On a related subject, do you know how I can track the progress of the play? I want to show progress as time passing or time remaining. This seems to need a constant feed of information from the player.
Thanks again,
Thanks. I see that there is a playstarted and playpaused too. That's perfect.
On a related subject, do you know how I can track the progress of the play? I want to show progress as time passing or time remaining. This seems to need a constant feed of information from the player.
Thanks again,
Alex Adams
(a)2 Technology Parnters
alex@a2technology.com
www.a2technology.com
www.promisstudio.com
831-726-8013
(a)2 Technology Parnters
alex@a2technology.com
www.a2technology.com
www.promisstudio.com
831-726-8013
Re: Need a message that a player is finished
This may be related to what I'm trying to do, so I'm posting here as a continuation of this thread.
I'm using Player objects to play audio on a card. The player is hidden, and play is started with a button on the card. I don't want the user to be able to click on other buttons until the Player has finished.
If I were using an audio file inside the stack, I'd use "wait until the sound is done" to hold things up. Is there a corresponding way to work with a Player object?
I tried this code:
but it caused the stack to hang... I never got control back and had to abort the script.
Thanks,
Doug
I'm using Player objects to play audio on a card. The player is hidden, and play is started with a button on the card. I don't want the user to be able to click on other buttons until the Player has finished.
If I were using an audio file inside the stack, I'd use "wait until the sound is done" to hold things up. Is there a corresponding way to work with a Player object?
I tried this code:
Code: Select all
on mouseUp
start player "9-1"
wait until the playstopped of player "9-1" is true
end mouseUp
Thanks,
Doug
Re: Need a message that a player is finished
Hi Doug,
"plasstopped" is a message and not a property!
In your script the engine presumes "the playstopped" is a custom property of the player and waits until this property = true, which never happens.
And since "wait" is blocking so you are erm... licked
As you might have read in this thread you could check
...
if the currenttime of player xyz = the duration of player xyz then
## Sound is finished!
...
Best
Klaus
"plasstopped" is a message and not a property!
In your script the engine presumes "the playstopped" is a custom property of the player and waits until this property = true, which never happens.
And since "wait" is blocking so you are erm... licked
As you might have read in this thread you could check
...
if the currenttime of player xyz = the duration of player xyz then
## Sound is finished!
...
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Re: Need a message that a player is finished
I think it's rude to block the user when a sound is playing.
The problem with wait is that it cancels every message too. See the following non working example (will block your ide, but you can use ctrl-. (peripod) to cancel):
Because of that fact, you might consider blocking clicks by overlaying a see trough object (using blending), for example a rectangle graphic. Watch out for keyboard stuff too.
The problem with wait is that it cancels every message too. See the following non working example (will block your ide, but you can use ctrl-. (peripod) to cancel):
Code: Select all
on playStarted
set the finished of me to false
wait until the finished of me = true
end playStarted
on playStopped --never happens
set the finished of me to true
end playStopped
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: Need a message that a player is finished
Klaus, thanks for the tip. Here's what I implemented, which works for me:
And BvG, thanks for your interface comment about it being rude to block the user. I added a visual indicator by disabling the other two buttons on the screen while the audio is playing.
Code: Select all
start player "9-1"
wait until (the currenttime of player "9-1" = the duration of player "9-1") is true