mirror of
https://github.com/yattee/yattee.git
synced 2024-12-14 14:20:32 +05:30
6eba2a45c8
I added a new feature. When instances are not proxied, Yattee first checks the URL to make sure it is not a restricted video. Usually, music videos and sports content can only be played back by the same IP address that requested the URL in the first place. That is why some videos do not play when the proxy is disabled. This approach has multiple advantages. First and foremost, It reduced the load on Invidious/Piped instances, since users can now directly access the videos without going through the instance, which might be severely bandwidth limited. Secondly, users don't need to manually turn on the proxy when they want to watch IP address bound content, since Yattee automatically proxies such content. Furthermore, adding the proxy option allows mitigating some severe playback issues with invidious instances. Invidious by default returns proxied URLs for videos, and due to some bug in the Invidious proxy, scrubbing or continuing playback at a random timestamp can lead to severe wait times for the users. This should fix numerous playback issues: #666, #626, #590, #585, #498, #457, #400
51 lines
1.5 KiB
Swift
51 lines
1.5 KiB
Swift
import Foundation
|
|
|
|
final class NetworkStateModel: ObservableObject {
|
|
static var shared = NetworkStateModel()
|
|
|
|
@Published var pausedForCache = false
|
|
@Published var cacheDuration = 0.0
|
|
@Published var bufferingState = 0.0
|
|
|
|
private var player: PlayerModel! { .shared }
|
|
private let controlsOverlayModel = ControlOverlaysModel.shared
|
|
|
|
var osdVisible: Bool {
|
|
guard let player else { return false }
|
|
return player.isPlaying && ((player.activeBackend == .mpv && pausedForCache) || player.isSeeking) && bufferingState < 100.0
|
|
}
|
|
|
|
var fullStateText: String? {
|
|
guard let bufferingStateText,
|
|
let cacheDurationText
|
|
else {
|
|
return nil
|
|
}
|
|
|
|
return "\(bufferingStateText) (\(cacheDurationText))"
|
|
}
|
|
|
|
var bufferingStateText: String? {
|
|
guard detailsAvailable && player.hasStarted else { return nil }
|
|
return String(format: "%.0f%%", bufferingState)
|
|
}
|
|
|
|
var cacheDurationText: String? {
|
|
guard detailsAvailable else { return nil }
|
|
return String(format: "%.2fs", cacheDuration)
|
|
}
|
|
|
|
var detailsAvailable: Bool {
|
|
guard let player else { return false }
|
|
return player.activeBackend.supportsNetworkStateBufferingDetails
|
|
}
|
|
|
|
var needsUpdates: Bool {
|
|
if let player {
|
|
return !player.currentItem.isNil && (pausedForCache || player.isSeeking || player.isLoadingVideo || controlsOverlayModel.presenting)
|
|
}
|
|
|
|
return false
|
|
}
|
|
}
|