Index: Slim/Control/Queries.pm =================================================================== --- Slim/Control/Queries.pm (revision 25903) +++ Slim/Control/Queries.pm (working copy) @@ -206,6 +206,9 @@ $request->addResultLoop($loopname, $cnt, 'repeat', $alarm->repeat()); $request->addResultLoop($loopname, $cnt, 'time', $alarm->time()); $request->addResultLoop($loopname, $cnt, 'volume', $alarm->volume()); + $request->addResultLoop($loopname, $cnt, 'usesDefaultVolume', $alarm->usesDefaultVolume() ? 1 : 0); + $request->addResultLoop($loopname, $cnt, 'timeout', $alarm->timeout()); + $request->addResultLoop($loopname, $cnt, 'usesDefaultTimeout', $alarm->usesDefaultTimeout() ? 1 : 0); $request->addResultLoop($loopname, $cnt, 'url', $alarm->playlist() || 'CURRENT_PLAYLIST'); $cnt++; } Index: Slim/Control/Commands.pm =================================================================== --- Slim/Control/Commands.pm (revision 25903) +++ Slim/Control/Commands.pm (working copy) @@ -77,7 +77,7 @@ my $client = $request->client(); my $cmd = $request->getParam('_cmd'); - my @tags = qw( id dow dowAdd dowDel enabled repeat time volume playlisturl url cmd ); + my @tags = qw( id dow dowAdd dowDel enabled repeat time volume timeout playlisturl url cmd ); # legacy support for "bare" alarm cli command (i.e., sending all tagged params) my $params; @@ -212,7 +212,13 @@ } } - $alarm->volume($params->{volume}) if defined $params->{volume}; + # volume and timeout can both be cleared by setting to '-' + if (defined $params->{volume}) { + $alarm->volume($params->{volume} == '-' ? undef : $params->{volume}); + } + if (defined $params->{timeout}) { + $alarm->timeout($params->{timeout} == '-' ? undef : $params->{timeout}); + } $alarm->enabled($params->{enabled}) if defined $params->{enabled}; $alarm->repeat($params->{repeat}) if defined $params->{repeat}; Index: Slim/Player/Client.pm =================================================================== --- Slim/Player/Client.pm (revision 25903) +++ Slim/Player/Client.pm (working copy) @@ -44,7 +44,7 @@ 'alarmDefaultVolume' => 50, # if this is changed, also change the hardcoded value in the prefs migration code in Prefs.pm 'alarmSnoozeSeconds' => 540, # 9 minutes 'alarmfadeseconds' => 1, # whether to fade in the volume for alarms. Boolean only, despite the name! - 'alarmTimeoutSeconds' => 3600, # time after which to automatically end an alarm. false to never end + 'alarmTimeoutSeconds' => 3600, # time after which to automatically end an alarm. 0 means never end 'lameQuality' => 9, 'playername' => \&_makeDefaultName, Index: Slim/Utils/Alarm.pm =================================================================== --- Slim/Utils/Alarm.pm (revision 25903) +++ Slim/Utils/Alarm.pm (working copy) @@ -68,7 +68,7 @@ # Values that should be passed through client->string are surrounded with curly braces. # e.g. # { -# 'randomplay://albums' => '{PLUGIN_RANDOM_ALBUMS}', +# 'randomplay://album' => '{PLUGIN_RANDOM_ALBUMS}', # } my %alarmPlaylists = (); @@ -121,6 +121,7 @@ _playlist => undef, _title => undef, _volume => undef, # Use default volume + _timeoutSeconds => undef, # Use per-client timeout value _active => 0, _snoozeActive => 0, _nextDue => undef, @@ -291,11 +292,39 @@ return $self->{_id}; } +=head 3 timeout ( [ $timeoutSeconds ] ) + +Sets/returns the number of seconds that this alarm will sound for before automatically timing out. This +is a fixed value and is not relative to how long an alarm has been active for. + +To make an alarm use the default, per-client setting, set $timeoutSeconds to undef. To prevent the alarm +from timing out, set it to zero. + +N.B. This feature is not exposed in the default user-interfaces. Alarms all use the same timeout value +as specified by the client pref, alarmTimeoutSeconds. + +=cut + +sub timeout { + my $self = shift; + + if (@_) { + $self->{_timeoutSeconds} = shift; + } + + if (defined $self->{_timeoutSeconds}) { + return $self->{_timeoutSeconds}; + } else { + # No explicit timeout defined so alarm uses per-client setting + return $prefs->client($self->client)->alarmTimeoutSeconds; + } +} + =head3 volume( [ $volume ] ) -Sets/returns the volume at which this alarm will sound. +Sets/returns the volume at which this alarm will sound. If set to undef, the default volume will be used. -N.B. This feature is not exposed in the default interfaces. Alarms all use the default volume. +N.B. This feature is not exposed in the default user-interfaces. Alarms all use the default volume. =cut @@ -321,10 +350,31 @@ return $self->{_volume}; } else { # No explicit volume defined so alarm uses default volume - return ref($self)->defaultVolume($self->client); + return $class->defaultVolume($self->client); } } +=head3 usesDefaultTimeout( [ 1 ] ) + +Sets/returns whether this alarm uses the default timeout or has it's own timeout setting. Set to 1 to use the default. + +To stop an alarm using the default timeout, set its timeout to something. + +N.B. This feature is not exposed in the default interfaces. Alarms all use the default timeout. + +=cut + +sub usesDefaultTimeout { + my $self = shift; + my $default = shift; + + if ($default) { + $self->{_timeoutSeconds} = undef; + } + + return ! defined $self->{_timeoutSeconds}; +} + =head3 usesDefaultVolume( [ 1 ] ) Sets/returns whether this alarm uses the default volume or has it's own volume setting. Set to 1 to use the default. @@ -682,7 +732,7 @@ $class->_setAlarmSubscription($client); # Set up subscription to automatically end the alarm if requested - my $timeout = $prefs->client($client)->alarmTimeoutSeconds; + my $timeout = $self->timeout; if ($timeout) { $log->debug("Scheduling time out in $timeout seconds"); $self->{_timeoutTimer} = Slim::Utils::Timers::setTimer($self, Time::HiRes::time + $timeout, \&_timeout); @@ -738,7 +788,7 @@ # Reset the alarm timeout timer so the alarm will now time out in timeoutSeconds + snoozeTime if (defined $self->{_timeoutTimer}) { - my $timeout = $prefs->client($client)->alarmTimeoutSeconds; + my $timeout = $self->timeout; Slim::Utils::Timers::killSpecific($self->{_timeoutTimer}); $log->debug(sub {'Scheduling automatic timeout in ' . ($timeout + $snoozeSeconds) . ' seconds'}); $self->{_timeoutTimer} = @@ -1557,10 +1607,10 @@ Slim::Utils::Alarm->addPlaylists('PLUGIN_RANDOMPLAY', [ - { title => '{PLUGIN_RANDOM_TRACK}', url => 'randomplay:track' }, - { title => '{PLUGIN_RANDOM_CONTRIBUTOR}', url => 'randomplay:contributor' }, - { title => '{PLUGIN_RANDOM_ALBUM}', url => 'randomplay:album' }, - { title => '{PLUGIN_RANDOM_YEAR}', url => 'randomplay:year' }, + { title => '{PLUGIN_RANDOM_TRACK}', url => 'randomplay://track' }, + { title => '{PLUGIN_RANDOM_CONTRIBUTOR}', url => 'randomplay://contributor' }, + { title => '{PLUGIN_RANDOM_ALBUM}', url => 'randomplay://album' }, + { title => '{PLUGIN_RANDOM_YEAR}', url => 'randomplay://year' }, ] ); @@ -1592,8 +1642,8 @@ { type => 'Random Mix', items => [ - { title => 'Song Mix', url => 'randomplay://albums' }, - { title => 'Album Mix', url => 'randomplay://artists' }, + { title => 'Song Mix', url => 'randomplay://album' }, + { title => 'Album Mix', url => 'randomplay://artist' }, ... ], }, Index: HTML/EN/html/docs/cli-api.html =================================================================== --- HTML/EN/html/docs/cli-api.html (revision 25903) +++ HTML/EN/html/docs/cli-api.html (working copy) @@ -7637,7 +7637,7 @@

- The "alarm" command allows to manipulate player alarms. + The "alarm" command manipulates player alarms.

Accepted tagged parameters: @@ -7647,15 +7647,7 @@ Tag Description - - id The id of an existing alarm. This value is mandatory unless you "add" a new alarm. @@ -7691,8 +7683,12 @@ Time of the alarm, in seconds from midnight. Mandatory when add command is issued + timeout + Number of seconds until the alarm ends automatically. Setting this to 0 will disable the automatic timeout; setting to '-' will make the alarm use the default timeout setting. Default: use the per-client setting for all alarms, as per the alarmTimeoutSeconds pref. + + volume - Mixer volume of the alarm. Default: use the default volume for alarms. Mandatory when defaultvolume command is issued + Mixer volume of the alarm. Set to '-' to use the default volume setting. Default: use the default volume for alarms. Mandatory when defaultvolume command is issued url (or playlisturl) @@ -7702,10 +7698,10 @@ The special value 0 means the current playlist.
Example values:

See also "favorites items". @@ -7732,11 +7728,14 @@ playlist:file://some/playlist.m3u time:9000 id:eaf39<LF>"

Deleting an alarm
Request: "bd:a5:a9:9b:9d:df alarm delete id:eaf39<LF>" -
Response: "bd:a5:a9:9b:9d:df alarm delete id:eaf39<LF>"

+
Response: "bd:a5:a9:9b:9d:df alarm delete id:eaf39 id:eaf39<LF>"

Enabling a previously defined alarm for Mo-Fr
Request: "bd:a5:a9:9b:9d:df alarm update id:eaf39 dow:1,2,3,4,5 enabled:1<LF>" -
Response: "bd:a5:a9:9b:9d:df alarm update id:eaf39 dow:1,2,3,4,5 enabled:1 count:1 - <LF>"

+
Response: "bd:a5:a9:9b:9d:df alarm update id:eaf39 dow:1,2,3,4,5 enabled:1 count:1 id:eaf39<LF>"

+

Setting a custom volume and timeout for an alarm +
Request: "bd:a5:a9:9b:9d:df alarm update id:eaf39 volume:75 timeout:600<LF>" +
Response: "bd:a5:a9:9b:9d:df alarm update id:eaf39 volume:75 timeout:600 id:eaf39<LF>" +

@@ -7860,23 +7859,35 @@ Days Of Week of this alarm. -   enabled +   enabled 1 if the alarm is enabled. -   repeat +   repeat 1 if the alarm repeats. -   time +   time Time of the alarm, in seconds from midnight. -   volume +   timeout + Number of seconds until alarm the alarm ends automatically (0 = infinite). + + +   usesDefaultTimeout + Whether this alarm uses the default timeout for all alarms. + + +   volume Mixer volume of the alarm. -   url +   usesDefaultVolume + Whether this alarm uses the default volume for all alarms. + + +   url URL of the alarm playlist, or "CURRENT_PLAYLIST" @@ -7887,10 +7898,9 @@

Request: "bd:a5:a9:9b:9d:df alarms 0 3<LF>"
- Response: "bd:a5:a9:9b:9d:df alarms 0 3 count:2 fade:0 dow:1 enabled:1 - time:3600 volume:50 url:randomplay://track dow:5 enabled:1 time:81000 - volume:77 playlist url:file:///Volumes/Smurf/playlists/Playlists/AAA.m3u - <LF>" + Response: "00:04:20:10:01:a3 alarms 0 3 fade:1 count:1 id:f026ba8d dow:0,1,2,3,4,5,6 + enabled:1 repeat:1 time:45720 volume:100 usesDefaultVolume:1 timeout:30 + usesDefaultTimeout:1 url:randomplay://track<LF>"