Limit progress updates

This commit is contained in:
Aiden Vigue 2021-06-10 17:54:14 -07:00
parent 968bd487b3
commit eb5f21bf5d
No known key found for this signature in database
GPG Key ID: 86E07E6D0CC00721
6 changed files with 20 additions and 17 deletions

View File

@ -459,8 +459,8 @@ struct EpisodeItemView: View {
}
}
.onAppear(perform: {
favorite = item.userData!.isFavorite!
watched = item.userData!.played!
favorite = item.userData?.isFavorite ?? false
watched = item.userData?.played ?? false
settingState = false
})
.navigationBarTitleDisplayMode(.inline)

View File

@ -85,12 +85,12 @@ struct LibrarySearchView: View {
.foregroundColor(.primary)
.lineLimit(1)
if item.productionYear != nil {
Text(String(item.productionYear ?? 0))
Text(String(item.productionYear!))
.foregroundColor(.secondary)
.font(.caption)
.fontWeight(.medium)
} else {
Text(item.type!)
Text(item.type ?? "")
}
}.frame(width: 100)
}

View File

@ -123,12 +123,12 @@ struct LibraryView: View {
.foregroundColor(.primary)
.lineLimit(1)
if item.productionYear != nil {
Text(String(item.productionYear ?? 0))
Text(String(item.productionYear!))
.foregroundColor(.secondary)
.font(.caption)
.fontWeight(.medium)
} else {
Text(item.type!)
Text(item.type ?? "")
}
}.frame(width: 100)
}

View File

@ -463,12 +463,12 @@ struct MovieItemView: View {
}
}
.onAppear(perform: {
favorite = item.userData!.isFavorite!
watched = item.userData!.played!
favorite = item.userData?.isFavorite ?? false
watched = item.userData?.played ?? false
settingState = false
})
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(item.name!)
.navigationTitle(item.name ?? "")
.supportedOrientations(.allButUpsideDown)
.overrideViewPreference(.unspecified)
.preferredColorScheme(.none)

View File

@ -92,6 +92,7 @@ struct SeriesItemView: View {
}
.overrideViewPreference(.unspecified)
.navigationTitle(item.name ?? "")
.navigationBarTitleDisplayMode(.inline)
}
}
}

View File

@ -509,15 +509,17 @@ class PlayerViewController: UIViewController, VLCMediaDelegate, VLCMediaPlayerDe
// MARK: Jellyfin Playstate updates
func sendProgressReport(eventName: String) {
let progressInfo = PlaybackProgressInfo(canSeek: true, item: manifest, itemId: manifest.id, sessionId: playSessionId, mediaSourceId: manifest.id, audioStreamIndex: Int(selectedAudioTrack), subtitleStreamIndex: Int(selectedCaptionTrack), isPaused: (mediaPlayer.state == .paused), isMuted: false, positionTicks: Int64(mediaPlayer.position * Float(manifest.runTimeTicks!)), playbackStartTimeTicks: Int64(startTime), volumeLevel: 100, brightness: 100, aspectRatio: nil, playMethod: playbackItem.videoType, liveStreamId: nil, playSessionId: playSessionId, repeatMode: .repeatNone, nowPlayingQueue: [], playlistItemId: "playlistItem0")
if (eventName == "timeupdate" && mediaPlayer.state == .playing) || eventName != "timeupdate" {
let progressInfo = PlaybackProgressInfo(canSeek: true, item: manifest, itemId: manifest.id, sessionId: playSessionId, mediaSourceId: manifest.id, audioStreamIndex: Int(selectedAudioTrack), subtitleStreamIndex: Int(selectedCaptionTrack), isPaused: (mediaPlayer.state == .paused), isMuted: false, positionTicks: Int64(mediaPlayer.position * Float(manifest.runTimeTicks!)), playbackStartTimeTicks: Int64(startTime), volumeLevel: 100, brightness: 100, aspectRatio: nil, playMethod: playbackItem.videoType, liveStreamId: nil, playSessionId: playSessionId, repeatMode: .repeatNone, nowPlayingQueue: [], playlistItemId: "playlistItem0")
PlaystateAPI.reportPlaybackProgress(playbackProgressInfo: progressInfo)
.sink(receiveCompletion: { completion in
HandleAPIRequestCompletion(globalData: self.globalData, completion: completion)
}, receiveValue: { _ in
print("Playback progress report sent!")
})
.store(in: &globalData.pendingAPIRequests)
PlaystateAPI.reportPlaybackProgress(playbackProgressInfo: progressInfo)
.sink(receiveCompletion: { completion in
HandleAPIRequestCompletion(globalData: self.globalData, completion: completion)
}, receiveValue: { _ in
print("Playback progress report sent!")
})
.store(in: &globalData.pendingAPIRequests)
}
}
func sendStopReport() {