Merge pull request #766 from stonerl/music-mode-thumbnail

make thumbnail fill the view in music mode
This commit is contained in:
Arkadiusz Fal 2024-08-31 12:47:52 +02:00 committed by GitHub
commit 8a84db5a2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -248,31 +248,33 @@ struct PlayerControls: View {
return [player.playerSize.height - inset, 500].min()! return [player.playerSize.height - inset, 500].min()!
} }
@ViewBuilder var controlsBackground: some View { @ViewBuilder
ZStack { var controlsBackground: some View {
if player.musicMode, GeometryReader { geometry in
let url = controlsBackgroundURL ZStack {
{ if player.musicMode,
ThumbnailView(url: url) let video = player.videoForDisplay
.frame(maxWidth: .infinity, maxHeight: .infinity) {
.transition(.opacity) let thumbnail = thumbnails.best(video)
.animation(.default) if let url = thumbnail.url,
} else if player.videoForDisplay == nil { let quality = thumbnail.quality
Color.black {
let aspectRatio = (quality == .default || quality == .high) ? Constants.aspectRatio4x3 : Constants.aspectRatio16x9
ThumbnailView(url: url)
.aspectRatio(aspectRatio, contentMode: .fill)
.frame(width: geometry.size.width, height: geometry.size.height)
.transition(.opacity)
.animation(.default)
.clipped()
}
} else if player.videoForDisplay == nil {
Color.black
}
} }
} }
} }
var controlsBackgroundURL: URL? {
if let video = player.videoForDisplay,
let url = thumbnails.best(video).url
{
return url
}
return nil
}
var timeline: some View { var timeline: some View {
TimelineView(context: .player).foregroundColor(.primary) TimelineView(context: .player).foregroundColor(.primary)
} }