Index: IR/Default.map =================================================================== --- IR/Default.map (revision 18699) +++ IR/Default.map (working copy) @@ -51,7 +51,10 @@ power_on = power_on add.single = add add.hold = zap -sleep = sleep +sleep.single = sleep +sleep.hold = sleep +snooze.single = snooze +snooze.hold = sleep stop = stop voldown = volume_down voldown.repeat = volume_down Index: IR/Slim_Devices_Remote.ir =================================================================== --- IR/Slim_Devices_Remote.ir (revision 18699) +++ IR/Slim_Devices_Remote.ir (working copy) @@ -6,7 +6,7 @@ ################################################################################## # Button names to IR code mappings ################################################################################## -0 = 76899867 +snooze = 76899867 1 = 7689f00f 2 = 768908f7 3 = 76898877 Index: Slim/Buttons/AlarmClock.pm =================================================================== --- Slim/Buttons/AlarmClock.pm (revision 18699) +++ Slim/Buttons/AlarmClock.pm (working copy) @@ -39,6 +39,7 @@ my $FADESECONDS = 20; # fade-in of 20 seconds my %menuSelection; +my %snooze = (); our %specialPlaylists; our %menuParams = (); our %functions = (); @@ -486,6 +487,9 @@ if ($time == $alarmtime) { $client->execute(['stop']); + + # register handler for starting mix of last type on remote button press [Default is press and hold shuffle] + # Slim::Buttons::Common::setFunction('snooze', \&snoozeCallback); my $volume = $prefs->client($client)->get('alarmvolume')->[ $day ]; @@ -554,6 +558,44 @@ Slim::Utils::Timers::setTimer($client, Time::HiRes::time() + 2, \&visibleAlarm, $client); } +sub snooze { + my $client = shift; + + # don't snooze again if we're already snoozing. + if (!$snooze{$client}) { + $client->execute(['stop']); + + # set up 10m snooze + $snooze{$client} = Time::HiRes::time() + (10 * 60); + + Slim::Utils::Timers::setTimer($client, $snooze{$client}, \&snoozeEnd, $client); + + $client->showBriefly({ + 'line' => [$client->string('ALARM_NOW_PLAYING'),$client->string('PLUGIN_ALARM_SNOOZE')], + 'duration' => 3, + 'block' => 1, + }); + } + + +} + +sub snoozeEnd { + my $client = shift; + + $snooze{$client} = 0; + + $client->execute(["playlist", "jump", "+1"]); + + Slim::Player::Playlist::refreshPlaylist($client); + + $client->showBriefly({ + 'line' => [$client->string('ALARM_NOW_PLAYING'),$client->string('PLUGIN_ALARM_WAKEUP')], + 'duration' => 3, + 'block' => 1, + }); +} + # temporary lines shown after alarm triggers, just to let the user know why the music started. sub alarmLines { my $client = shift; @@ -583,6 +625,7 @@ # show visible alert for 30s $client->showBriefly(alarmLines($client), 30); + $client->modeParam('alarmactive',1); } sub overlayFunc { Index: Slim/Buttons/Common.pm =================================================================== --- Slim/Buttons/Common.pm (revision 18699) +++ Slim/Buttons/Common.pm (working copy) @@ -943,9 +943,25 @@ $client->execute(["mixer", "muting", $mute]); }, + 'snooze' => sub { + my $client = shift; + + if ($client->modeParam('alarmactive')) { + Slim::Buttons::AlarmClock::snooze($client); + } + }, + 'sleep' => sub { my $client = shift; + # sleep function is overridden when alarm activates + if ($client->modeParam('alarmactive')) { + + $log->info("Alarm Active: sleep function override for snooze"); + Slim::Buttons::AlarmClock::snooze($client); + return; + } + # Bug: 2151 some extra stuff to add the option to sleep after the current song. # first make sure we're playing, and its a valid song. my $remaining = 0;