is there a generic handler for the player status?

Eric Chatonet eric.chatonet at sosmartsoftware.com
Tue Jun 3 09:39:25 EDT 2008


Bonjour Tiemo,

AFAIK no.

But for fun (and it will sure lean up your code :-):

In each player, put:

local lPlayerStatus
----------------------------------------
on playStarted
   put char 5 to -1 of the params into lPlayerStatus
end playStarted
----------------------------------------
on playPaused
   put char 5 to -1 of the params into lPlayerStatus
end playPaused
----------------------------------------
on playStopped
   put char 5 to -1 of the params into lPlayerStatus
end playStopped
----------------------------------------
on PlayerCurStatus
   return lPlayerStatus
end PlayerCurStatus

And in the card or the stack script:

function PlayerStatus pPlayer
   call "PlayerCurStatus" of pPlayer
   return the result
end PlayerStatus

Now you can use the PlayerStatus function with a param that is the  
long name of any player to know its status:
empty: the user did not pay attention yet to the player
Started: the player is running
Paused: the player is paused
Stopped: the player has reached its end

Example:

switch PlayerStatus(the long name of player "Player1")
   case "Started"
   <statements>
   break
   case "Paused"
   <statements>
   break
   case "Stopped"
   <statements>
   break
   default -- empty
   <statements>
end switch

In this code, one another interesting thing is that it uses the call  
command to bypass the message hierarchy and, in addition, uses a  
handler that fakes a function by returning a value.
As I said, just for fun and knowledge ;-)

Le 3 juin 08 à 14:42, Tiemo Hollmann TB a écrit :

> to ask for the player status there are the handlers playStarted,  
> playStopped
> and playPaused.
>
> Is the also a generic handler with the status as a param to ask for  
> the
> status? (just to lean up my code a bit?)
>
> Thanks
>
> Tiemo



Best regards from Paris,
Eric Chatonet.
----------------------------------------------------------------
Plugins and tutorials for Revolution: http://www.sosmartsoftware.com/
Email: eric.chatonet at sosmartsoftware.com/
----------------------------------------------------------------





More information about the use-livecode mailing list