mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Show stream opening status with AVPlayer
This commit is contained in:
parent
2b7ccc4b03
commit
c6798be167
@ -38,9 +38,7 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
!avPlayer.currentItem.isNil
|
||||
}
|
||||
|
||||
var isLoadingVideo: Bool {
|
||||
model.currentItem == nil || model.time == nil || !model.time!.isValid
|
||||
}
|
||||
var isLoadingVideo = false
|
||||
|
||||
var isPlaying: Bool {
|
||||
avPlayer.timeControlStatus == .playing
|
||||
@ -138,6 +136,8 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
preservingTime: Bool,
|
||||
upgrading _: Bool
|
||||
) {
|
||||
isLoadingVideo = true
|
||||
|
||||
if let url = stream.singleAssetURL {
|
||||
model.logger.info("playing stream with one asset\(stream.kind == .hls ? " (HLS)" : ""): \(url)")
|
||||
|
||||
@ -475,6 +475,8 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
return
|
||||
}
|
||||
|
||||
isLoadingVideo = false
|
||||
|
||||
switch playerItem.status {
|
||||
case .readyToPlay:
|
||||
if self.model.activeBackend == .appleAVPlayer,
|
||||
|
@ -32,6 +32,17 @@ extension PlayerModel {
|
||||
}
|
||||
}
|
||||
|
||||
var playerItemEndTimeWithSegments: CMTime? {
|
||||
if let duration = playerItemDuration,
|
||||
let segment = sponsorBlock.segments.last,
|
||||
segment.endTime.seconds >= duration.seconds - 3
|
||||
{
|
||||
return segment.endTime
|
||||
}
|
||||
|
||||
return playerItemDuration
|
||||
}
|
||||
|
||||
private func skip(_ segment: Segment, at time: CMTime) {
|
||||
if let duration = playerItemDuration, segment.endTime.seconds >= duration.seconds - 3 {
|
||||
logger.error("segment end time is: \(segment.end) when player item duration is: \(duration.seconds)")
|
||||
|
@ -42,6 +42,8 @@ struct PlayerControls: View {
|
||||
@Default(.playerControlsPlaybackModeEnabled) private var playerControlsPlaybackModeEnabled
|
||||
@Default(.playerControlsMusicModeEnabled) private var playerControlsMusicModeEnabled
|
||||
|
||||
@Default(.avPlayerUsesSystemControls) private var avPlayerUsesSystemControls
|
||||
|
||||
private let controlsOverlayModel = ControlOverlaysModel.shared
|
||||
private var navigation = NavigationModel.shared
|
||||
|
||||
@ -49,8 +51,13 @@ struct PlayerControls: View {
|
||||
player.playingFullScreen ? fullScreenPlayerControlsLayout : regularPlayerControlsLayout
|
||||
}
|
||||
|
||||
var showControls: Bool {
|
||||
player.activeBackend == .mpv || !avPlayerUsesSystemControls
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .topLeading) {
|
||||
if showControls {
|
||||
Seek()
|
||||
.zIndex(4)
|
||||
.transition(.opacity)
|
||||
@ -65,6 +72,7 @@ struct PlayerControls: View {
|
||||
#else
|
||||
.offset(y: 2)
|
||||
#endif
|
||||
}
|
||||
|
||||
VStack {
|
||||
ZStack {
|
||||
@ -78,6 +86,7 @@ struct PlayerControls: View {
|
||||
}
|
||||
.offset(y: playerControlsLayout.osdVerticalOffset + 5)
|
||||
|
||||
if showControls {
|
||||
Section {
|
||||
#if !os(tvOS)
|
||||
HStack {
|
||||
@ -180,6 +189,7 @@ struct PlayerControls: View {
|
||||
.opacity(model.presentingControls && !player.availableStreams.isEmpty ? 1 : 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity)
|
||||
#if os(tvOS)
|
||||
.onChange(of: model.presentingControls) { newValue in
|
||||
|
@ -48,12 +48,12 @@ struct PlayerBackendView: View {
|
||||
#if !os(tvOS)
|
||||
if player.activeBackend == .mpv || !avPlayerUsesSystemControls {
|
||||
PlayerGestures()
|
||||
}
|
||||
PlayerControls()
|
||||
#if os(iOS)
|
||||
.padding(.top, controlsTopPadding)
|
||||
.padding(.bottom, controlsBottomPadding)
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
hiddenControlsButton
|
||||
#endif
|
||||
|
@ -5,8 +5,15 @@ struct PlayerGestures: View {
|
||||
private var player = PlayerModel.shared
|
||||
@ObservedObject private var model = PlayerControlsModel.shared
|
||||
|
||||
@Default(.avPlayerUsesSystemControls) private var avPlayerUsesSystemControls
|
||||
|
||||
var showGestures: Bool {
|
||||
player.activeBackend == .mpv || !avPlayerUsesSystemControls
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
if showGestures {
|
||||
gestureRectangle
|
||||
.tapRecognizer(
|
||||
tapSensitivity: 0.2,
|
||||
@ -43,6 +50,7 @@ struct PlayerGestures: View {
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func singleTapAction() {
|
||||
if model.presentingOverlays {
|
||||
|
@ -2268,9 +2268,9 @@
|
||||
37992DC826CC50CD003D4C27 /* iOS */,
|
||||
37BE0BD826A214500092E2DB /* macOS */,
|
||||
37D4B159267164AE00C925CA /* tvOS */,
|
||||
37D4B1B72672CFE300C925CA /* Model */,
|
||||
37D4B0C12671614700C925CA /* Shared */,
|
||||
3722AEBA274DA312005EA4D6 /* Backports */,
|
||||
37D4B1B72672CFE300C925CA /* Model */,
|
||||
37C7A9022679058300E721B4 /* Extensions */,
|
||||
37DD9DCC2785EE6F00539416 /* Vendor */,
|
||||
3748186426A762300084E870 /* Fixtures */,
|
||||
|
Loading…
Reference in New Issue
Block a user