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