ios: hide progress controls for live streams
All checks were successful
TestFlight / testflight (push) Successful in 1m23s
All checks were successful
TestFlight / testflight (push) Successful in 1m23s
This commit is contained in:
@@ -61,7 +61,7 @@ struct NowPlayingMiniView: View {
|
|||||||
}
|
}
|
||||||
.padding(EdgeInsets(top: 4.0, leading: 14.0, bottom: 4.0, trailing: 10.0))
|
.padding(EdgeInsets(top: 4.0, leading: 14.0, bottom: 4.0, trailing: 10.0))
|
||||||
|
|
||||||
if model.playbackDuration != nil {
|
if model.seekablePlaybackDuration != nil {
|
||||||
TimelineView(.periodic(from: .now, by: 1.0)) { context in
|
TimelineView(.periodic(from: .now, by: 1.0)) { context in
|
||||||
ProgressView(value: model.playbackProgress(at: context.date) ?? 0.0)
|
ProgressView(value: model.playbackProgress(at: context.date) ?? 0.0)
|
||||||
.progressViewStyle(.linear)
|
.progressViewStyle(.linear)
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ class NowPlayingViewModel
|
|||||||
return duration
|
return duration
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var seekablePlaybackDuration: Double? {
|
||||||
|
guard isSeekable else { return nil }
|
||||||
|
return playbackDuration
|
||||||
|
}
|
||||||
|
|
||||||
var displayedPlaybackPosition: Double {
|
var displayedPlaybackPosition: Double {
|
||||||
displayedPlaybackPosition(at: .now)
|
displayedPlaybackPosition(at: .now)
|
||||||
}
|
}
|
||||||
@@ -55,8 +60,8 @@ class NowPlayingViewModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
func playbackProgress(at date: Date) -> Double? {
|
func playbackProgress(at date: Date) -> Double? {
|
||||||
guard let playbackDuration else { return nil }
|
guard let seekablePlaybackDuration else { return nil }
|
||||||
return displayedPlaybackPosition(at: date) / playbackDuration
|
return displayedPlaybackPosition(at: date) / seekablePlaybackDuration
|
||||||
}
|
}
|
||||||
|
|
||||||
func syncPlaybackPosition(_ position: Double?, duration: Double?, isPlaying: Bool, isSeekable: Bool) {
|
func syncPlaybackPosition(_ position: Double?, duration: Double?, isPlaying: Bool, isSeekable: Bool) {
|
||||||
@@ -108,7 +113,7 @@ struct NowPlayingView: View
|
|||||||
|
|
||||||
Spacer(minLength: 20.0)
|
Spacer(minLength: 20.0)
|
||||||
|
|
||||||
if let duration = model.playbackDuration {
|
if let duration = model.seekablePlaybackDuration {
|
||||||
TimelineView(.periodic(from: .now, by: 1.0)) { context in
|
TimelineView(.periodic(from: .now, by: 1.0)) { context in
|
||||||
VStack(spacing: 2.0) {
|
VStack(spacing: 2.0) {
|
||||||
Slider(
|
Slider(
|
||||||
@@ -116,7 +121,7 @@ struct NowPlayingView: View
|
|||||||
in: 0.0...duration,
|
in: 0.0...duration,
|
||||||
onEditingChanged: playbackPositionEditingChanged
|
onEditingChanged: playbackPositionEditingChanged
|
||||||
)
|
)
|
||||||
.disabled(!model.isSeekable || nothingQueued)
|
.disabled(nothingQueued)
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
Text(formatTime(model.displayedPlaybackPosition(at: context.date)))
|
Text(formatTime(model.displayedPlaybackPosition(at: context.date)))
|
||||||
|
|||||||
Reference in New Issue
Block a user