mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 16:42:01 +00:00
bug fixes
Some checks are pending
Build and Release IPA / Build IPA and Mac Catalyst (push) Waiting to run
Some checks are pending
Build and Release IPA / Build IPA and Mac Catalyst (push) Waiting to run
This commit is contained in:
parent
031a36cd75
commit
4dbe5e8c2b
5 changed files with 23 additions and 3 deletions
Binary file not shown.
|
|
@ -32,6 +32,8 @@ struct CustomMediaPlayer: View {
|
||||||
@State private var showControls = false
|
@State private var showControls = false
|
||||||
@State private var inactivityTimer: Timer?
|
@State private var inactivityTimer: Timer?
|
||||||
@State private var timeObserverToken: Any?
|
@State private var timeObserverToken: Any?
|
||||||
|
@State private var isVideoLoaded = false
|
||||||
|
@State private var showWatchNextButton = true
|
||||||
@Environment(\.presentationMode) var presentationMode
|
@Environment(\.presentationMode) var presentationMode
|
||||||
|
|
||||||
let module: ModuleStruct
|
let module: ModuleStruct
|
||||||
|
|
@ -76,6 +78,7 @@ struct CustomMediaPlayer: View {
|
||||||
currentTime = time.seconds
|
currentTime = time.seconds
|
||||||
if let itemDuration = player.currentItem?.duration.seconds, itemDuration.isFinite && !itemDuration.isNaN {
|
if let itemDuration = player.currentItem?.duration.seconds, itemDuration.isFinite && !itemDuration.isNaN {
|
||||||
duration = itemDuration
|
duration = itemDuration
|
||||||
|
isVideoLoaded = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
startUpdatingCurrentTime()
|
startUpdatingCurrentTime()
|
||||||
|
|
@ -152,7 +155,7 @@ struct CustomMediaPlayer: View {
|
||||||
.padding(.horizontal, 32)
|
.padding(.horizontal, 32)
|
||||||
}
|
}
|
||||||
Spacer()
|
Spacer()
|
||||||
if duration - currentTime <= duration * 0.10 && currentTime != duration {
|
if duration - currentTime <= duration * 0.10 && currentTime != duration && showWatchNextButton {
|
||||||
Button(action: {
|
Button(action: {
|
||||||
player.pause()
|
player.pause()
|
||||||
presentationMode.wrappedValue.dismiss()
|
presentationMode.wrappedValue.dismiss()
|
||||||
|
|
@ -170,6 +173,13 @@ struct CustomMediaPlayer: View {
|
||||||
.cornerRadius(32)
|
.cornerRadius(32)
|
||||||
}
|
}
|
||||||
.padding(.trailing, 10)
|
.padding(.trailing, 10)
|
||||||
|
.onAppear {
|
||||||
|
if UserDefaults.standard.bool(forKey: "hideNextButton") {
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
|
||||||
|
showWatchNextButton = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if showControls {
|
if showControls {
|
||||||
Menu {
|
Menu {
|
||||||
|
|
@ -203,13 +213,14 @@ struct CustomMediaPlayer: View {
|
||||||
emptyColor: .white.opacity(0.3),
|
emptyColor: .white.opacity(0.3),
|
||||||
height: 28,
|
height: 28,
|
||||||
onEditingChanged: { editing in
|
onEditingChanged: { editing in
|
||||||
if !editing {
|
if !editing && isVideoLoaded {
|
||||||
player.seek(to: CMTime(seconds: currentTime, preferredTimescale: 600))
|
player.seek(to: CMTime(seconds: currentTime, preferredTimescale: 600))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.padding(.horizontal, 32)
|
.padding(.horizontal, 32)
|
||||||
.padding(.bottom, 10)
|
.padding(.bottom, 10)
|
||||||
|
.disabled(!isVideoLoaded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,9 @@ import SwiftSoup
|
||||||
|
|
||||||
extension MediaView {
|
extension MediaView {
|
||||||
func fetchItemDetails() {
|
func fetchItemDetails() {
|
||||||
|
guard !isFetchingStream else { return }
|
||||||
|
isFetchingStream = true
|
||||||
|
|
||||||
guard let url = URL(string: item.href.hasPrefix("https") ? item.href : "\(module.module[0].details.baseURL.hasSuffix("/") ? module.module[0].details.baseURL : "\(module.module[0].details.baseURL)/")\(item.href.hasPrefix("/") ? String(item.href.dropFirst()) : item.href)") else { return }
|
guard let url = URL(string: item.href.hasPrefix("https") ? item.href : "\(module.module[0].details.baseURL.hasSuffix("/") ? module.module[0].details.baseURL : "\(module.module[0].details.baseURL)/")\(item.href.hasPrefix("/") ? String(item.href.dropFirst()) : item.href)") else { return }
|
||||||
|
|
||||||
URLSession.custom.dataTask(with: url) { data, _, error in
|
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||||
|
|
@ -47,6 +50,7 @@ extension MediaView {
|
||||||
Logger.shared.log("Error parsing HTML: \(error)")
|
Logger.shared.log("Error parsing HTML: \(error)")
|
||||||
}
|
}
|
||||||
}.resume()
|
}.resume()
|
||||||
|
isFetchingStream = false
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchEpisodeStream(urlString: String) {
|
func fetchEpisodeStream(urlString: String) {
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,8 @@ struct MediaView: View {
|
||||||
@State private var selectedEpisode: String = ""
|
@State private var selectedEpisode: String = ""
|
||||||
@State private var selectedEpisodeNumber: Int = 0
|
@State private var selectedEpisodeNumber: Int = 0
|
||||||
@State private var episodeRange: ClosedRange<Int> = 0...99
|
@State private var episodeRange: ClosedRange<Int> = 0...99
|
||||||
@State private var selectedRange: String = "1-100"
|
@State var selectedRange: String = "1-100"
|
||||||
|
@State var isFetchingStream: Bool = false
|
||||||
|
|
||||||
@AppStorage("externalPlayer") private var externalPlayer: String = "Default"
|
@AppStorage("externalPlayer") private var externalPlayer: String = "Default"
|
||||||
@StateObject private var libraryManager = LibraryManager.shared
|
@StateObject private var libraryManager = LibraryManager.shared
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import SwiftUI
|
||||||
struct SettingsPlayerView: View {
|
struct SettingsPlayerView: View {
|
||||||
@AppStorage("externalPlayer") private var externalPlayer: String = "Default"
|
@AppStorage("externalPlayer") private var externalPlayer: String = "Default"
|
||||||
@AppStorage("AlwaysLandscape") private var isAlwaysLandscape = false
|
@AppStorage("AlwaysLandscape") private var isAlwaysLandscape = false
|
||||||
|
@AppStorage("hideNextButton") private var isHideNextButton = false
|
||||||
@AppStorage("holdSpeedPlayer") private var holdSpeedPlayer: Double = 2.0
|
@AppStorage("holdSpeedPlayer") private var holdSpeedPlayer: Double = 2.0
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
@ -52,6 +53,9 @@ struct SettingsPlayerView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toggle("Hide 'Watch Next' after 5s", isOn: $isHideNextButton)
|
||||||
|
.tint(.accentColor)
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
Text("Hold Speed:")
|
Text("Hold Speed:")
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue