From 80d8d66986dd033452cc5a4096d5756d01087a1e Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Fri, 11 Nov 2022 19:19:48 +0100 Subject: [PATCH] Local videos fixes --- Model/Player/PlayerModel.swift | 2 +- Model/Player/PlayerQueue.swift | 9 +++++++-- Shared/Player/Controls/PlayerControls.swift | 4 ++-- Shared/Videos/VideoCell.swift | 4 ++-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index 556f422a..f03f9a92 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -806,7 +806,7 @@ final class PlayerModel: ObservableObject { #if os(macOS) var windowTitle: String { - currentVideo.isNil ? "Not Playing" : "\(currentVideo!.title) - \(currentVideo!.author)" + currentVideo.isNil ? "Not Playing" : "\(currentVideo!.displayTitle) - \(currentVideo!.displayAuthor)" } #else func handleEnterForeground() { diff --git a/Model/Player/PlayerQueue.swift b/Model/Player/PlayerQueue.swift index 14d45961..fb84e596 100644 --- a/Model/Player/PlayerQueue.swift +++ b/Model/Player/PlayerQueue.swift @@ -59,16 +59,21 @@ extension PlayerModel { DispatchQueue.main.async { [weak self] in guard let self else { return } - guard let video = self.currentVideo else { + guard let video = item.video else { return } self.videoBeingOpened = nil + if video.isLocal { + self.availableStreams = video.streams + return + } + guard let playerInstance = self.playerInstance else { return } let streamsInstance = video.streams.compactMap(\.instance).first - if !video.isLocal, video.streams.isEmpty || streamsInstance != playerInstance { + if video.streams.isEmpty || streamsInstance != playerInstance { self.loadAvailableStreams(video) } else { self.availableStreams = self.streamsWithInstance(instance: playerInstance, streams: video.streams) diff --git a/Shared/Player/Controls/PlayerControls.swift b/Shared/Player/Controls/PlayerControls.swift index 13623e7a..71ef8710 100644 --- a/Shared/Player/Controls/PlayerControls.swift +++ b/Shared/Player/Controls/PlayerControls.swift @@ -111,12 +111,12 @@ struct PlayerControls: View { if playerControlsLayout.displaysTitleLine { VStack(alignment: .leading) { - Text(player.currentVideo?.title ?? "Not Playing") + Text(player.currentVideo?.displayTitle ?? "Not Playing") .shadow(radius: 10) .font(.system(size: playerControlsLayout.titleLineFontSize).bold()) .lineLimit(1) - Text(player.currentVideo?.channel.name ?? "") + Text(player.currentVideo?.displayAuthor ?? "") .fontWeight(.semibold) .shadow(radius: 10) .foregroundColor(.secondary) diff --git a/Shared/Videos/VideoCell.swift b/Shared/Videos/VideoCell.swift index 34e2260d..98435d87 100644 --- a/Shared/Videos/VideoCell.swift +++ b/Shared/Videos/VideoCell.swift @@ -163,7 +163,7 @@ struct VideoCell: View { .frame(maxWidth: 320) VStack(alignment: .leading, spacing: 0) { - videoDetail(video.title, lineLimit: 5) + videoDetail(video.displayTitle, lineLimit: 5) .frame(minWidth: 0, maxWidth: .infinity, alignment: .leading) if !channelOnThumbnail, !inChannelView { @@ -240,7 +240,7 @@ struct VideoCell: View { VStack(alignment: .leading, spacing: 0) { Group { VStack(alignment: .leading, spacing: 0) { - videoDetail(video.title, lineLimit: 2) + videoDetail(video.displayTitle, lineLimit: 2) #if os(tvOS) .frame(minHeight: 60, alignment: .top) #elseif os(macOS)