YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.snapcast.ui.SnapcastVolumeKeys Class Reference

The hardware volume keys on the focused Snapcast group (11.4). More...

Collaboration diagram for de.yaacc.snapcast.ui.SnapcastVolumeKeys:
Collaboration graph

Classes

class  Decision
 What one key press does to a group.
 
enum  Direction
 The two keys. More...
 
interface  Model
 What the row of a group shows now (volume, mute, controllable); null when the group is not known. More...
 
class  Result
 What the Android code shows after a press.
 
interface  Sink
 Where the changes go. More...
 

Public Member Functions

 SnapcastVolumeKeys (Model model, Sink sink, MonotonicClock clock)
 
void volumeChanged (String receiverId, int percent)
 The user set the group volume with the slider (card or sheet): the next key starts from that value, not from the value of an earlier key press or from a model that has not caught up.
 
void muteChanged (String receiverId, boolean muted)
 The user muted or unmuted the group with the symbol: the next key starts from that state; the volume is the one a key press asked for a moment ago, else the model's.
 
Result press (String receiverId, Direction direction)
 A key press on the group of receiverId (the id of its receiver row).
 

Static Public Member Functions

static Decision decide (Direction direction, int percent, boolean muted, boolean controllable)
 The decision for one press.
 

Static Public Attributes

static final int STEP_PERCENT = 5
 Points of the group volume for one key press.
 
static final long PENDING_MILLIS = 2_000L
 A press this soon after the last one continues from the value the last press asked for.
 

Detailed Description

The hardware volume keys on the focused Snapcast group (11.4).

Pure Java: which group is the target is decided by SnapcastKeyFocus, the Android code only passes the key and shows the answer.

  • One step is {@value STEP_PERCENT} points of the group volume (the average of the connected members, set through SnapcastControls#setGroupVolume: every member moves by the same number of points), clamped to 0..100.
  • Mute. "Up" on a muted group unmutes it and raises the volume (as the system does for its streams); "down" on a muted group changes nothing but is still taken, so the phone's own volume does not move instead. At the ends of the range the key is taken and nothing is sent.
  • Not controllable (the server does not answer, no member is connected, the group is not known): the key is not taken and the system keeps it, as before 11.4.
  • A held key repeats faster than the server's answer comes back and the model catches up, so a press within {@value PENDING_MILLIS} ms of the last one goes on from the value the last press asked for.

Every change goes through the one Sink (the app's SnapcastControls): off the main thread, coalesced, failures as a toast.

Member Function Documentation

◆ decide()

static Decision de.yaacc.snapcast.ui.SnapcastVolumeKeys.decide ( Direction direction,
int percent,
boolean muted,
boolean controllable )
static

The decision for one press.

Parameters
percentthe group volume now, -1 when there is none
controllablewhether a change makes sense (the server answers and a member is connected)

Referenced by de.yaacc.snapcast.ui.SnapcastVolumeKeys.press().

Here is the caller graph for this function:

◆ press()

Result de.yaacc.snapcast.ui.SnapcastVolumeKeys.press ( String receiverId,
Direction direction )

A key press on the group of receiverId (the id of its receiver row).

Returns
what happened; not handled when the group can not be controlled
Here is the call graph for this function:

◆ volumeChanged()

void de.yaacc.snapcast.ui.SnapcastVolumeKeys.volumeChanged ( String receiverId,
int percent )

The user set the group volume with the slider (card or sheet): the next key starts from that value, not from the value of an earlier key press or from a model that has not caught up.

The mute state is the group's as the model shows it.


The documentation for this class was generated from the following file: