PDA

View Full Version : How to get active alarm time in applet ?



erland
2010-02-08, 22:41
Is there any way to get the time of an active alarm from inside an applet without doing an extra query to the server ?

I know I can do something like this to get the time of the next alarm:


local player = appletManager:callService("getCurrentPlayer")
local alarmtime = player:getPlayerStatus()["alarm_next"]


Can I do something similar to get the time of the currently active alarm ?

bluegaspode
2010-02-09, 00:29
Isn't the 'next' alarm the time of the currently active alarm ?
Or do you mean 'the time of the alarm currently playing and showing a popup' ?

You can also get hold of the AlarmSnoozeApplet and call its 'alarmNext' variable. Or listen to notifyPlayerAlarmState (alarmState=active) and cache the value (alarm next or just the current time) like the alarmSnoozeApplet does.

erland
2010-02-09, 01:03
Isn't the 'next' alarm the time of the currently active alarm ?

The "alarm_next" parameter refers to the alarm that is about to be triggered next, not the one that is currently active. It's reset after the alarm is triggered.



Or do you mean 'the time of the alarm currently playing and showing a popup' ?

Yes



You can also get hold of the AlarmSnoozeApplet and call its 'alarmNext' variable.

I'd like to avoid accessing internal states variables since it can easily be renamed to changed and then my applet would stop working.



Or listen to notifyPlayerAlarmState (alarmState=active) and cache the value (alarm next or just the current time) like the alarmSnoozeApplet does.

Yes, I know, the problem is just that this is in a screen saver which I'd prefer to not be loaded all the time. I think this would use more resources than necessary, but I'm not sure.

bklaas
2010-02-09, 06:03
Yes, I know, the problem is just that this is in a screen saver which I'd prefer to not be loaded all the time. I think this would use more resources than necessary, but I'm not sure.

It won't be loaded until the notification comes in.

at the top of your applet, subscribe to the notifications with jnt


local jnt = jnt


then add a function to capture the playerAlarmState notification



function notify_playerAlarmState(self, player, alarmState, alarmNext)
--self is your applet's self
--player will be the player object for the notification
--alarmState will be 'set', 'none', 'snooze', or 'active'
--alarmNext will be given in epochsecs

end


That may be enough for you but if not, next step would be for me to add a getAlarmNext method to the Player class. That's probably very simple, though we'd need to work out the logic on what it would send back when an alarm is currently active/snoozing.

#!/ben

pippin
2010-02-09, 07:27
It won't be loaded until the notification comes in.

at the top of your applet, subscribe to the notifications with jnt


local jnt = jnt


then add a function to capture the playerAlarmState notification



function notify_playerAlarmState(self, player, alarmState, alarmNext)
--self is your applet's self
--player will be the player object for the notification
--alarmState will be 'set', 'none', 'snooze', or 'active'
--alarmNext will be given in epochsecs

end



That notification looks undocumented. How do I subscribe to it?
I mean: over CLI/cometd