playlist GUI
This commit is contained in:
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"mxl-player/internal/playback"
|
||||
@@ -135,3 +136,41 @@ func shouldAutoStartPlaylist(
|
||||
args.AudioFlowId == "" &&
|
||||
len(playlist.Entries) > 0
|
||||
}
|
||||
|
||||
func playlistEntryDisplayName(entry playback.PlaylistEntry, index int) string {
|
||||
if entry.Name != "" {
|
||||
return entry.Name
|
||||
}
|
||||
return fmt.Sprintf("Entry %d", index+1)
|
||||
}
|
||||
|
||||
func playlistTimingProgress(
|
||||
timing playback.PlaylistTimingState,
|
||||
now time.Time,
|
||||
) (float32, time.Duration) {
|
||||
if timing.Duration <= 0 {
|
||||
return 0, 0
|
||||
}
|
||||
if timing.Expired {
|
||||
return 1, 0
|
||||
}
|
||||
if !timing.Started {
|
||||
return 0, timing.Duration
|
||||
}
|
||||
|
||||
remaining := timing.Deadline.Sub(now)
|
||||
if remaining < 0 {
|
||||
remaining = 0
|
||||
}
|
||||
if remaining > timing.Duration {
|
||||
remaining = timing.Duration
|
||||
}
|
||||
fraction := 1 - float32(remaining)/float32(timing.Duration)
|
||||
if fraction < 0 {
|
||||
fraction = 0
|
||||
}
|
||||
if fraction > 1 {
|
||||
fraction = 1
|
||||
}
|
||||
return fraction, remaining
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user