New setting: Avoid playlist randomization
Some checks are pending
continuous-integration/drone/push Build is running
Some checks are pending
continuous-integration/drone/push Build is running
This commit is contained in:
parent
34917043ce
commit
8cdfde856e
4 changed files with 22 additions and 7 deletions
|
@ -17,6 +17,7 @@ type Settings struct {
|
|||
MaxRunTime time.Duration `json:"max_run_time"`
|
||||
MaxVolume uint16 `json:"max_volume"`
|
||||
StartVolume uint16 `json:"start_volume"`
|
||||
NoRandom bool `json:"no_random"`
|
||||
Federation map[string]FederationServer `json:"federation"`
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ type Player struct {
|
|||
MaxRunTime time.Duration
|
||||
MaxVolume uint16
|
||||
StartVolume uint16
|
||||
NoRandom bool
|
||||
Stopper chan bool
|
||||
currentCmd *exec.Cmd
|
||||
currentCmdCh chan bool
|
||||
|
@ -97,11 +98,12 @@ func NewPlayer(cfg *config.Config, routines []reveil.Identifier) (*Player, error
|
|||
MaxRunTime: settings.MaxRunTime * time.Minute,
|
||||
MaxVolume: uint16(settings.MaxVolume),
|
||||
StartVolume: uint16(settings.StartVolume),
|
||||
NoRandom: settings.NoRandom,
|
||||
weatherTime: settings.WeatherDelay * time.Minute,
|
||||
weatherAction: wact,
|
||||
claironTime: settings.GongInterval * time.Minute,
|
||||
claironFile: reveil.CurrentGongPath(cfg),
|
||||
reverseOrder: int(time.Now().Unix()/86400)%2 == 0,
|
||||
reverseOrder: !settings.NoRandom && int(time.Now().Unix()/86400)%2 == 0,
|
||||
}
|
||||
|
||||
// Load routines
|
||||
|
@ -131,11 +133,13 @@ func NewPlayer(cfg *config.Config, routines []reveil.Identifier) (*Player, error
|
|||
p.Playlist = append(p.Playlist, track.Path)
|
||||
}
|
||||
|
||||
log.Println("Shuffling playlist...")
|
||||
// Shuffle the playlist
|
||||
rand.Shuffle(len(p.Playlist), func(i, j int) {
|
||||
p.Playlist[i], p.Playlist[j] = p.Playlist[j], p.Playlist[i]
|
||||
})
|
||||
if !p.NoRandom {
|
||||
log.Println("Shuffling playlist...")
|
||||
// Shuffle the playlist
|
||||
rand.Shuffle(len(p.Playlist), func(i, j int) {
|
||||
p.Playlist[i], p.Playlist[j] = p.Playlist[j], p.Playlist[i]
|
||||
})
|
||||
}
|
||||
|
||||
return &p, nil
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ export class Settings {
|
|||
}
|
||||
}
|
||||
|
||||
update({ language, gong_interval, weather_delay, weather_action, pre_alarm_delay, pre_alarm_action, max_run_time, max_volume, start_volume, federation }) {
|
||||
update({ language, gong_interval, weather_delay, weather_action, pre_alarm_delay, pre_alarm_action, max_run_time, max_volume, start_volume, no_random, federation }) {
|
||||
this.language = language;
|
||||
this.gong_interval = gong_interval;
|
||||
this.weather_delay = weather_delay;
|
||||
|
@ -15,6 +15,7 @@ export class Settings {
|
|||
this.max_run_time = max_run_time;
|
||||
this.max_volume = max_volume;
|
||||
this.start_volume = start_volume;
|
||||
this.no_random = no_random;
|
||||
this.federation = federation;
|
||||
}
|
||||
|
||||
|
|
|
@ -174,6 +174,15 @@
|
|||
</InputGroup>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<Input
|
||||
type="switch"
|
||||
label="Ne pas mélanger la liste de lecture"
|
||||
bind:checked={settings.no_random}
|
||||
on:input={() => submitSettings(settings)}
|
||||
/>
|
||||
</FormGroup>
|
||||
|
||||
<FormGroup>
|
||||
<Label for="federation">Federation</Label>
|
||||
<FederationSettings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue