Re: LMS & time/timer/timing

AF1 <AF1.aoqjvb-NUepA2SMhDQqspMVqqL2D+4xXEVPTSb/[email protected]> Sat, 6 Aug 2022 12:30:40 +0000
Newsgroups gmane.music.equipment.slimdevices.devel
Organization Logitech Squeezebox Forums
Message-ID <[email protected]>
mherger wrote: 
> > I'd like to *trigger a function at a _specific_ time*: hh:mm -
> accurate
> > to the minute is all I need. I know you can set alarms for clients.
> But
> > how would I do that server-side *without* clients?[/color]
> 
> Server-side you can use Slim::Utils::Timers::setTimer() to execute some
> 
> code at a given time. You'll have to calculate the execution time 
> yourself as epochtime: date()+secondsToWantedTime. See 
> https://github.com/Logitech/slimserver/blob/public/8.3/Slim/Utils/Timers.pm
> 

I use timers just the way you describe here and below (incl. preventing
multiple timers for the same event) in some of my plugins. 
I guess, looking at alarms, I'd hoped that I could 'outsource' *all* of
the time keeping to LMS, more or less like alarms work but without
clients. I'll set my own timer then.

mherger wrote: 
> > If a plugin requires the exact/*accurate* playback time (i.e. *time
> > elapsed*) of a *song on a client*, not just once but *continuously*,
> I
> > could start a timer with the plugin when a song starts on a client
> > though I don't know how accurate/synced that would be. Is there any
> > other way to do this?
> 
> Please define "continuously": do you need it every second? More than 
> once a second? As you might know LMS is single-threaded. You can't run 
> this in a loop or something.
> 
> But you could again use a timer. setHighTimer() allows you to use more 
> granular resolution than 1s. This then could call 
> Slim::Player::Source::songTime($client) to get a client's playtime.
> 
> It's good practice to kill all timers for any given event when the event
> 
> handler is called. This is to prevent multiple timers for the same event
> 
> to happen. And then, when you're done processing whatever you need, you
> 
> set a new timer for the next execution.
> 
> If that's not what you're looking for, then you might describe in a 
> larger picture what you're trying to do.

I was reading about syncing lyrics display to songs (in a browser).
You'd have some sorft of subtitle file (e.g. Aegisub) that includes the
exact time code (often up to the ms) for when a (partial) lyrics string
should be displayed. 
So if timers are the only way, I guess you'd have to parse all time
markers and corresponding lyrics strings from the subtitle file and then
set a timer, display lyrics string, set next timer... Unless you know
another way.



'Ratings Light FAQ' (https://github.com/AF-1/lms-ratingslight) ••••
'Dynamic Playlists 3 FAQ'
(https://github.com/AF-1/lms-dynamicplaylists#faq) ••••
'*List of all plugins*'
(https://github.com/AF-1/all-repos-and-links)
------------------------------------------------------------------------
AF1's Profile: http://forums.slimdevices.com/member.php?userid=39306
View this thread: http://forums.slimdevices.com/showthread.php?t=116641

_______________________________________________
developers mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/developers