tv settings, channel item improvements
This commit is contained in:
parent
c2ad99ba83
commit
4bea0ddf43
|
@ -27,7 +27,7 @@ final class LiveTVVideoPlayerCoordinator: NavigationCoordinatable {
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
func makeStart() -> some View {
|
func makeStart() -> some View {
|
||||||
if Defaults[.Experimental.nativePlayer] {
|
if Defaults[.Experimental.liveTVNativePlayer] {
|
||||||
LiveTVNativeVideoPlayerView(viewModel: viewModel)
|
LiveTVNativeVideoPlayerView(viewModel: viewModel)
|
||||||
.navigationBarHidden(true)
|
.navigationBarHidden(true)
|
||||||
.ignoresSafeArea()
|
.ignoresSafeArea()
|
||||||
|
|
|
@ -226,7 +226,7 @@ extension BaseItemDto {
|
||||||
mediaSourceId: mediaSourceID)
|
mediaSourceId: mediaSourceID)
|
||||||
directStreamURL = URL(string: directStreamBuilder.URLString)!
|
directStreamURL = URL(string: directStreamBuilder.URLString)!
|
||||||
|
|
||||||
if let transcodeURL = currentMediaSource.transcodingUrl, !Defaults[.Experimental.forceDirectPlay] {
|
if let transcodeURL = currentMediaSource.transcodingUrl, !Defaults[.Experimental.liveTVForceDirectPlay] {
|
||||||
streamType = .transcode
|
streamType = .transcode
|
||||||
transcodedStreamURL = URLComponents(string: SessionManager.main.currentLogin.server.currentURI
|
transcodedStreamURL = URLComponents(string: SessionManager.main.currentLogin.server.currentURI
|
||||||
.appending(transcodeURL))!
|
.appending(transcodeURL))!
|
||||||
|
|
|
@ -74,8 +74,10 @@ extension Defaults.Keys {
|
||||||
static let syncSubtitleStateWithAdjacent = Key<Bool>("experimental.syncSubtitleState", default: false,
|
static let syncSubtitleStateWithAdjacent = Key<Bool>("experimental.syncSubtitleState", default: false,
|
||||||
suite: SwiftfinStore.Defaults.generalSuite)
|
suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
static let forceDirectPlay = Key<Bool>("forceDirectPlay", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
static let forceDirectPlay = Key<Bool>("forceDirectPlay", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
static let liveTVAlphaEnabled = Key<Bool>("liveTVAlphaEnabled", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
|
||||||
static let nativePlayer = Key<Bool>("nativePlayer", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
static let nativePlayer = Key<Bool>("nativePlayer", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
static let liveTVAlphaEnabled = Key<Bool>("liveTVAlphaEnabled", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
static let liveTVForceDirectPlay = Key<Bool>("liveTVForceDirectPlay", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
|
static let liveTVNativePlayer = Key<Bool>("liveTVNativePlayer", default: false, suite: SwiftfinStore.Defaults.generalSuite)
|
||||||
}
|
}
|
||||||
|
|
||||||
// tvos specific
|
// tvos specific
|
||||||
|
|
|
@ -10,28 +10,61 @@ import JellyfinAPI
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LiveTVChannelItemElement: View {
|
struct LiveTVChannelItemElement: View {
|
||||||
@Environment(\.isFocused)
|
@FocusState
|
||||||
var envFocused: Bool
|
private var focused: Bool
|
||||||
@State
|
@State
|
||||||
var focused: Bool = false
|
private var loading: Bool = false
|
||||||
|
@State
|
||||||
|
private var isFocused: Bool = false
|
||||||
|
|
||||||
var channel: BaseItemDto
|
var channel: BaseItemDto
|
||||||
var program: BaseItemDto?
|
var program: BaseItemDto?
|
||||||
var startString = " "
|
var startString = " "
|
||||||
var endString = " "
|
var endString = " "
|
||||||
var progressPercent = Double(0)
|
var progressPercent = Double(0)
|
||||||
|
var onSelect: (@escaping (Bool) -> Void) -> Void
|
||||||
|
|
||||||
|
private var detailText: String {
|
||||||
|
guard let program = program else {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
var text = ""
|
||||||
|
if let season = program.parentIndexNumber,
|
||||||
|
let episode = program.indexNumber
|
||||||
|
{
|
||||||
|
text.append("\(season)x\(episode) ")
|
||||||
|
} else if let episode = program.indexNumber {
|
||||||
|
text.append("\(episode) ")
|
||||||
|
}
|
||||||
|
if let title = program.episodeTitle {
|
||||||
|
text.append("\(title) ")
|
||||||
|
}
|
||||||
|
if let year = program.productionYear {
|
||||||
|
text.append("\(year) ")
|
||||||
|
}
|
||||||
|
if let rating = program.officialRating {
|
||||||
|
text.append("\(rating)")
|
||||||
|
}
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
ZStack {
|
||||||
VStack {
|
VStack {
|
||||||
HStack {
|
HStack {
|
||||||
Spacer()
|
|
||||||
Text(channel.number ?? "")
|
Text(channel.number ?? "")
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.frame(alignment: .trailing)
|
.frame(alignment: .leading)
|
||||||
|
.padding()
|
||||||
|
Spacer()
|
||||||
}.frame(alignment: .top)
|
}.frame(alignment: .top)
|
||||||
ImageView(channel.getPrimaryImage(maxWidth: 125))
|
Spacer()
|
||||||
.frame(width: 125, alignment: .center)
|
}
|
||||||
.offset(x: 0, y: -32)
|
VStack {
|
||||||
|
ImageView(channel.getPrimaryImage(maxWidth: 128))
|
||||||
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.frame(width: 128, alignment: .center)
|
||||||
|
.padding(.init(top: 8, leading: 0, bottom: 0, trailing: 0))
|
||||||
Text(channel.name ?? "?")
|
Text(channel.name ?? "?")
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
@ -40,7 +73,14 @@ struct LiveTVChannelItemElement: View {
|
||||||
.font(.body)
|
.font(.body)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
.foregroundColor(.green)
|
.foregroundColor(.green)
|
||||||
|
Text(detailText)
|
||||||
|
.font(.body)
|
||||||
|
.lineLimit(1)
|
||||||
|
.foregroundColor(.green)
|
||||||
|
Spacer()
|
||||||
|
HStack(alignment: .bottom) {
|
||||||
VStack {
|
VStack {
|
||||||
|
Spacer()
|
||||||
HStack {
|
HStack {
|
||||||
Text(startString)
|
Text(startString)
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
|
@ -64,17 +104,33 @@ struct LiveTVChannelItemElement: View {
|
||||||
.fill(Color.jellyfinPurple)
|
.fill(Color.jellyfinPurple)
|
||||||
.frame(width: CGFloat(progressPercent * gp.size.width), height: 12)
|
.frame(width: CGFloat(progressPercent * gp.size.width), height: 12)
|
||||||
}
|
}
|
||||||
|
.frame(alignment: .bottom)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
.background(Color.clear)
|
.opacity(loading ? 0.5 : 1.0)
|
||||||
.border(focused ? Color.blue : Color.clear, width: 4)
|
|
||||||
.onChange(of: envFocused) { envFocus in
|
if loading {
|
||||||
|
ProgressView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.overlay(RoundedRectangle(cornerRadius: 20)
|
||||||
|
.stroke(isFocused ? Color.blue : Color.clear, lineWidth: 4))
|
||||||
|
.cornerRadius(20)
|
||||||
|
.scaleEffect(isFocused ? 1.1 : 1)
|
||||||
|
.focusable(true)
|
||||||
|
.focused($focused)
|
||||||
|
.onChange(of: focused) { foc in
|
||||||
withAnimation(.linear(duration: 0.15)) {
|
withAnimation(.linear(duration: 0.15)) {
|
||||||
self.focused = envFocus
|
self.isFocused = foc
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.onLongPressGesture(minimumDuration: 0.01, pressing: { _ in }) {
|
||||||
|
onSelect { loadingState in
|
||||||
|
loading = loadingState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.scaleEffect(focused ? 1.1 : 1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,24 +54,21 @@ struct LiveTVChannelsView: View {
|
||||||
let item = cell.item
|
let item = cell.item
|
||||||
let channel = item.channel
|
let channel = item.channel
|
||||||
if channel.type != "Folder" {
|
if channel.type != "Folder" {
|
||||||
Button {
|
|
||||||
self.viewModel.isLoading = true
|
|
||||||
self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in
|
|
||||||
self.router.route(to: \.videoPlayer, playerViewModel)
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
|
||||||
self.viewModel.isLoading = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} label: {
|
|
||||||
let progressPercent = item.program?.getLiveProgressPercentage() ?? 0
|
let progressPercent = item.program?.getLiveProgressPercentage() ?? 0
|
||||||
LiveTVChannelItemElement(channel: channel,
|
LiveTVChannelItemElement(channel: channel,
|
||||||
program: item.program,
|
program: item.program,
|
||||||
startString: item.program?.getLiveStartTimeString(formatter: viewModel.timeFormatter) ?? " ",
|
startString: item.program?.getLiveStartTimeString(formatter: viewModel.timeFormatter) ?? " ",
|
||||||
endString: item.program?.getLiveEndTimeString(formatter: viewModel.timeFormatter) ?? " ",
|
endString: item.program?.getLiveEndTimeString(formatter: viewModel.timeFormatter) ?? " ",
|
||||||
progressPercent: progressPercent > 1.0 ? 1.0 : progressPercent
|
progressPercent: progressPercent > 1.0 ? 1.0 : progressPercent,
|
||||||
)
|
onSelect: { loadingAction in
|
||||||
|
loadingAction(true)
|
||||||
|
self.viewModel.fetchVideoPlayerViewModel(item: channel) { playerViewModel in
|
||||||
|
self.router.route(to: \.videoPlayer, playerViewModel)
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 2) {
|
||||||
|
loadingAction(false)
|
||||||
}
|
}
|
||||||
.buttonStyle(PlainNavigationLinkButtonStyle())
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,16 @@ struct ExperimentalSettingsView: View {
|
||||||
var forceDirectPlay
|
var forceDirectPlay
|
||||||
@Default(.Experimental.syncSubtitleStateWithAdjacent)
|
@Default(.Experimental.syncSubtitleStateWithAdjacent)
|
||||||
var syncSubtitleStateWithAdjacent
|
var syncSubtitleStateWithAdjacent
|
||||||
@Default(.Experimental.liveTVAlphaEnabled)
|
|
||||||
var liveTVAlphaEnabled
|
|
||||||
@Default(.Experimental.nativePlayer)
|
@Default(.Experimental.nativePlayer)
|
||||||
var nativePlayer
|
var nativePlayer
|
||||||
|
|
||||||
|
@Default(.Experimental.liveTVAlphaEnabled)
|
||||||
|
var liveTVAlphaEnabled
|
||||||
|
@Default(.Experimental.liveTVForceDirectPlay)
|
||||||
|
var liveTVForceDirectPlay
|
||||||
|
@Default(.Experimental.liveTVNativePlayer)
|
||||||
|
var liveTVNativePlayer
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
Form {
|
||||||
Section {
|
Section {
|
||||||
|
@ -28,9 +33,19 @@ struct ExperimentalSettingsView: View {
|
||||||
|
|
||||||
Toggle("Sync Subtitles with Adjacent Episodes", isOn: $syncSubtitleStateWithAdjacent)
|
Toggle("Sync Subtitles with Adjacent Episodes", isOn: $syncSubtitleStateWithAdjacent)
|
||||||
|
|
||||||
|
Toggle("Native Player", isOn: $nativePlayer)
|
||||||
|
|
||||||
|
} header: {
|
||||||
|
L10n.experimental.text
|
||||||
|
}
|
||||||
|
|
||||||
|
Section {
|
||||||
|
|
||||||
Toggle("Live TV (Alpha)", isOn: $liveTVAlphaEnabled)
|
Toggle("Live TV (Alpha)", isOn: $liveTVAlphaEnabled)
|
||||||
|
|
||||||
Toggle("Native Player", isOn: $nativePlayer)
|
Toggle("Live TV Force Direct Play", isOn: $liveTVForceDirectPlay)
|
||||||
|
|
||||||
|
Toggle("Live TV Native Player", isOn: $liveTVNativePlayer)
|
||||||
|
|
||||||
} header: {
|
} header: {
|
||||||
L10n.experimental.text
|
L10n.experimental.text
|
||||||
|
|
Loading…
Reference in New Issue