mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 16:42:01 +00:00
TestFlight build (#101)
* Implementation of loading modal * little things but this is good * Update README.md * dim mode * hello 👋 (#95) * bug fix dimming * improved the fetchEpisodeMetadata logic * Aniskip logic and basic buttons (#96) * Aniskip logic and basic buttons * good fuckin enough for now * im callin good enough * bug fix * its something * hallelujah * Update SearchView.swift * made subs go up the progress bar if it is showing --------- Co-authored-by: Seiike <122684677+Seeike@users.noreply.github.com> Co-authored-by: Francesco <100066266+cranci1@users.noreply.github.com> * Updated workflow to change file extension from .zip to .ipa for easier access. (#98) * Update README.md * Auto: Update IPA [skip ci] * Color picker in settings for intro and outro segments (#99) * Color picker in settings for intro and outro segments * Color picker in settings for intro and outro segments * Auto: Update IPA [skip ci] --------- Co-authored-by: cranci1 <cranci1@github.com> --------- Co-authored-by: Ibrahim Sulejmenov <batonchik2004@gmail.com> Co-authored-by: ibro <54913038+xibrox@users.noreply.github.com> Co-authored-by: Seiike <122684677+Seeike@users.noreply.github.com> Co-authored-by: bshar <98615778+bshar1865@users.noreply.github.com> Co-authored-by: cranci1 <cranci1@github.com>
This commit is contained in:
parent
6cf88cb50d
commit
00586fcf3e
14 changed files with 995 additions and 431 deletions
22
.github/workflows/build.yml
vendored
22
.github/workflows/build.yml
vendored
|
|
@ -1,12 +1,15 @@
|
|||
name: Build and Release IPA
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build IPA
|
||||
runs-on: macOS-latest
|
||||
|
||||
steps:
|
||||
- name: Use Node.js 20
|
||||
uses: actions/setup-node@v4
|
||||
|
|
@ -15,15 +18,22 @@ jobs:
|
|||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: true
|
||||
|
||||
- name: Run ipabuild.sh
|
||||
run: |
|
||||
chmod +x ipabuild.sh
|
||||
./ipabuild.sh
|
||||
|
||||
- name: Upload IPA artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: Sulfur-IPA
|
||||
path: build/Sulfur.ipa
|
||||
compression-level: 0
|
||||
- name: Commit and push latest IPA
|
||||
run: |
|
||||
git config user.name "cranci1"
|
||||
git config user.email "cranci1@github.com"
|
||||
|
||||
mkdir -p public-build
|
||||
cp -f build/Sulfur.ipa public-build/Sulfur.ipa
|
||||
|
||||
git add -f public-build/Sulfur.ipa
|
||||
git diff --quiet && git diff --staged --quiet || git commit -m "Auto: Update IPA [skip ci]"
|
||||
git push
|
||||
|
|
|
|||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -63,10 +63,9 @@ DerivedData/
|
|||
*.hmap
|
||||
|
||||
## App packaging
|
||||
*.ipa
|
||||
*.dSYM.zip
|
||||
*.dSYM
|
||||
|
||||
public-build
|
||||
## Playgrounds
|
||||
timeline.xctimeline
|
||||
playground.xcworkspace
|
||||
|
|
|
|||
|
|
@ -23,11 +23,13 @@ An iOS and macOS modular web scraping app, under the GPLv3.0 License.
|
|||
|
||||
- [x] iOS/iPadOS 15.0+ support
|
||||
- [x] macOS support 12.0+
|
||||
- [x] Sync via iCloud data
|
||||
- [x] JavaScript module support
|
||||
- [x] Local Library
|
||||
- [x] Tracking Services (AniList, Trakt)
|
||||
- [x] Apple KeyChain support for auth Tokens
|
||||
- [x] Streams support (Jellyfin/Plex like servers)
|
||||
- [x] External Media players (VLC, infuse, Outplayer, nPlayer)
|
||||
- [x] Tracking Services (AniList, Trakt)
|
||||
- [x] Background playback and Picture-in-Picture (PiP) support
|
||||
|
||||
## Frequently Asked Questions
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ struct SoraApp: App {
|
|||
if isAuthenticated {
|
||||
Logger.shared.log("Trakt authentication is valid")
|
||||
} else {
|
||||
Logger.shared.log("Trakt authentication required", type: "Warning")
|
||||
Logger.shared.log("Trakt authentication required", type: "Error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,4 +101,51 @@ class AniListMutation {
|
|||
|
||||
task.resume()
|
||||
}
|
||||
|
||||
func fetchMalID(animeId: Int, completion: @escaping (Result<Int, Error>) -> Void) {
|
||||
let query = """
|
||||
query ($id: Int) {
|
||||
Media(id: $id) {
|
||||
idMal
|
||||
}
|
||||
}
|
||||
"""
|
||||
let variables: [String: Any] = ["id": animeId]
|
||||
let requestBody: [String: Any] = [
|
||||
"query": query,
|
||||
"variables": variables
|
||||
]
|
||||
guard let jsonData = try? JSONSerialization.data(withJSONObject: requestBody, options: []) else {
|
||||
completion(.failure(NSError(domain: "", code: -1,
|
||||
userInfo: [NSLocalizedDescriptionKey: "Failed to serialize GraphQL request"])))
|
||||
return
|
||||
}
|
||||
|
||||
var request = URLRequest(url: apiURL)
|
||||
request.httpMethod = "POST"
|
||||
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
|
||||
// no auth required for read
|
||||
request.httpBody = jsonData
|
||||
|
||||
URLSession.shared.dataTask(with: request) { data, resp, error in
|
||||
if let e = error {
|
||||
return completion(.failure(e))
|
||||
}
|
||||
guard let data = data,
|
||||
let json = try? JSONDecoder().decode(AniListMediaResponse.self, from: data),
|
||||
let mal = json.data.Media?.idMal else {
|
||||
return completion(.failure(NSError(domain: "", code: -1,
|
||||
userInfo: [NSLocalizedDescriptionKey: "Failed to decode AniList response or idMal missing"])))
|
||||
}
|
||||
completion(.success(mal))
|
||||
}.resume()
|
||||
}
|
||||
|
||||
private struct AniListMediaResponse: Decodable {
|
||||
struct DataField: Decodable {
|
||||
struct Media: Decodable { let idMal: Int? }
|
||||
let Media: Media?
|
||||
}
|
||||
let data: DataField
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,3 +44,30 @@ class VolumeViewModel: ObservableObject {
|
|||
@Published var value: Double = 0.0
|
||||
}
|
||||
|
||||
class SliderViewModel: ObservableObject {
|
||||
@Published var sliderValue: Double = 0.0
|
||||
@Published var introSegments: [ClosedRange<Double>] = []
|
||||
@Published var outroSegments: [ClosedRange<Double>] = []
|
||||
}
|
||||
|
||||
struct AniListMediaResponse: Decodable {
|
||||
struct DataField: Decodable {
|
||||
struct Media: Decodable { let idMal: Int? }
|
||||
let Media: Media?
|
||||
}
|
||||
let data: DataField
|
||||
}
|
||||
|
||||
struct AniSkipResponse: Decodable {
|
||||
struct Result: Decodable {
|
||||
struct Interval: Decodable {
|
||||
let startTime: Double
|
||||
let endTime: Double
|
||||
}
|
||||
let interval: Interval
|
||||
let skipType: String
|
||||
}
|
||||
let found: Bool
|
||||
let results: [Result]
|
||||
let statusCode: Int
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ struct MusicProgressSlider<T: BinaryFloatingPoint>: View {
|
|||
let emptyColor: Color
|
||||
let height: CGFloat
|
||||
let onEditingChanged: (Bool) -> Void
|
||||
let introSegments: [ClosedRange<T>] // Changed
|
||||
let outroSegments: [ClosedRange<T>] // Changed
|
||||
let introColor: Color
|
||||
let outroColor: Color
|
||||
|
||||
@State private var localRealProgress: T = 0
|
||||
@State private var localTempProgress: T = 0
|
||||
|
|
@ -28,8 +32,36 @@ struct MusicProgressSlider<T: BinaryFloatingPoint>: View {
|
|||
ZStack {
|
||||
VStack(spacing: 8) {
|
||||
ZStack(alignment: .center) {
|
||||
ZStack(alignment: .center) {
|
||||
// Intro Segments
|
||||
ForEach(introSegments, id: \.self) { segment in
|
||||
HStack(spacing: 0) {
|
||||
Spacer()
|
||||
.frame(width: bounds.size.width * CGFloat(segment.lowerBound))
|
||||
Rectangle()
|
||||
.fill(introColor.opacity(0.5))
|
||||
.frame(width: bounds.size.width * CGFloat(segment.upperBound - segment.lowerBound))
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
// Outro Segments
|
||||
ForEach(outroSegments, id: \.self) { segment in
|
||||
HStack(spacing: 0) {
|
||||
Spacer()
|
||||
.frame(width: bounds.size.width * CGFloat(segment.lowerBound))
|
||||
Rectangle()
|
||||
.fill(outroColor.opacity(0.5))
|
||||
.frame(width: bounds.size.width * CGFloat(segment.upperBound - segment.lowerBound))
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
|
||||
// Rest of the existing code...
|
||||
Capsule()
|
||||
.fill(emptyColor)
|
||||
}
|
||||
|
||||
Capsule()
|
||||
.fill(isActive ? activeFillColor : fillColor)
|
||||
.mask({
|
||||
|
|
|
|||
|
|
@ -11,13 +11,6 @@ import AVKit
|
|||
import SwiftUI
|
||||
import AVFoundation
|
||||
import MediaPlayer
|
||||
|
||||
// MARK: - SliderViewModel
|
||||
|
||||
class SliderViewModel: ObservableObject {
|
||||
@Published var sliderValue: Double = 0.0
|
||||
}
|
||||
|
||||
// MARK: - CustomMediaPlayerViewController
|
||||
|
||||
class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
|
|
@ -115,17 +108,49 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
var watchNextButtonControlsConstraints: [NSLayoutConstraint] = []
|
||||
var isControlsVisible = false
|
||||
|
||||
var subtitleBottomConstraint: NSLayoutConstraint?
|
||||
private var subtitleBottomToSliderConstraint: NSLayoutConstraint?
|
||||
private var subtitleBottomToSafeAreaConstraint: NSLayoutConstraint?
|
||||
var subtitleBottomPadding: CGFloat = 10.0 {
|
||||
didSet {
|
||||
updateSubtitleLabelConstraints()
|
||||
}
|
||||
}
|
||||
|
||||
private var malID: Int?
|
||||
private var skipIntervals: (op: CMTimeRange?, ed: CMTimeRange?) = (nil, nil)
|
||||
|
||||
private var skipIntroButton: UIButton!
|
||||
private var skipOutroButton: UIButton!
|
||||
private let skipButtonBaseAlpha: CGFloat = 0.9
|
||||
@Published var segments: [ClosedRange<Double>] = []
|
||||
|
||||
private var playerItemKVOContext = 0
|
||||
private var loadedTimeRangesObservation: NSKeyValueObservation?
|
||||
private var playerTimeControlStatusObserver: NSKeyValueObservation?
|
||||
|
||||
private var isDimmed = false
|
||||
private var dimButton: UIButton!
|
||||
private var dimButtonToSlider: NSLayoutConstraint!
|
||||
private var dimButtonToRight: NSLayoutConstraint!
|
||||
private var dimButtonTimer: Timer?
|
||||
|
||||
private lazy var controlsToHide: [UIView] = [
|
||||
dismissButton,
|
||||
playPauseButton,
|
||||
backwardButton,
|
||||
forwardButton,
|
||||
sliderHostingController!.view,
|
||||
skip85Button,
|
||||
marqueeLabel,
|
||||
menuButton,
|
||||
qualityButton,
|
||||
speedButton,
|
||||
watchNextButton,
|
||||
volumeSliderHostingView!
|
||||
]
|
||||
|
||||
private var originalHiddenStates: [UIView: Bool] = [:]
|
||||
|
||||
private var volumeObserver: NSKeyValueObservation?
|
||||
private var audioSession = AVAudioSession.sharedInstance()
|
||||
private var hiddenVolumeView = MPVolumeView(frame: .zero)
|
||||
|
|
@ -195,16 +220,32 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
setupSubtitleLabel()
|
||||
setupDismissButton()
|
||||
volumeSlider()
|
||||
setupDimButton()
|
||||
setupSpeedButton()
|
||||
setupQualityButton()
|
||||
setupMenuButton()
|
||||
setupMarqueeLabel()
|
||||
setupSkip85Button()
|
||||
setupSkipButtons()
|
||||
addTimeObserver()
|
||||
startUpdateTimer()
|
||||
setupAudioSession()
|
||||
updateSkipButtonsVisibility()
|
||||
|
||||
|
||||
AniListMutation().fetchMalID(animeId: aniListID) { [weak self] result in
|
||||
switch result {
|
||||
case .success(let mal):
|
||||
self?.malID = mal
|
||||
self?.fetchSkipTimes(type: "op")
|
||||
self?.fetchSkipTimes(type: "ed")
|
||||
case .failure(let error):
|
||||
Logger.shared.log("⚠️ Unable to fetch MAL ID: \(error)",type:"Error")
|
||||
}
|
||||
}
|
||||
|
||||
controlsToHide.forEach { originalHiddenStates[$0] = $0.isHidden }
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
|
||||
self?.checkForHLSStream()
|
||||
}
|
||||
|
|
@ -348,6 +389,14 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
}
|
||||
|
||||
private func getSegmentsColor() -> Color {
|
||||
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
|
||||
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {
|
||||
return Color(uiColor)
|
||||
}
|
||||
return .yellow
|
||||
}
|
||||
|
||||
func setupPlayerViewController() {
|
||||
playerViewController = AVPlayerViewController()
|
||||
playerViewController.player = player
|
||||
|
|
@ -458,6 +507,8 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
controlsContainerView.addSubview(forwardButton)
|
||||
forwardButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
let segmentsColor = self.getSegmentsColor()
|
||||
|
||||
let sliderView = MusicProgressSlider(
|
||||
value: Binding(
|
||||
get: { self.sliderViewModel.sliderValue },
|
||||
|
|
@ -489,7 +540,11 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
introSegments: sliderViewModel.introSegments, // Added
|
||||
outroSegments: sliderViewModel.outroSegments, // Added
|
||||
introColor: segmentsColor, // Add your colors here
|
||||
outroColor: segmentsColor // Or use settings.accentColor
|
||||
)
|
||||
|
||||
sliderHostingController = UIHostingController(rootView: sliderView)
|
||||
|
|
@ -641,19 +696,27 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
subtitleLabel.textAlignment = .center
|
||||
subtitleLabel.numberOfLines = 0
|
||||
subtitleLabel.font = UIFont.systemFont(ofSize: CGFloat(subtitleFontSize))
|
||||
updateSubtitleLabelAppearance()
|
||||
view.addSubview(subtitleLabel)
|
||||
subtitleLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
subtitleBottomConstraint = subtitleLabel.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: -subtitleBottomPadding)
|
||||
subtitleBottomToSliderConstraint = subtitleLabel.bottomAnchor.constraint(
|
||||
equalTo: sliderHostingController!.view.topAnchor,
|
||||
constant: -20
|
||||
)
|
||||
|
||||
subtitleBottomToSafeAreaConstraint = subtitleLabel.bottomAnchor.constraint(
|
||||
equalTo: view.safeAreaLayoutGuide.bottomAnchor,
|
||||
constant: -subtitleBottomPadding
|
||||
)
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
subtitleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
subtitleBottomConstraint!,
|
||||
subtitleLabel.leadingAnchor.constraint(greaterThanOrEqualTo: view.leadingAnchor, constant: 36),
|
||||
subtitleLabel.trailingAnchor.constraint(lessThanOrEqualTo: view.trailingAnchor, constant: -36)
|
||||
])
|
||||
|
||||
subtitleBottomToSafeAreaConstraint?.isActive = true
|
||||
|
||||
topSubtitleLabel = UILabel()
|
||||
topSubtitleLabel.textAlignment = .center
|
||||
topSubtitleLabel.numberOfLines = 0
|
||||
|
|
@ -662,6 +725,8 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
view.addSubview(topSubtitleLabel)
|
||||
topSubtitleLabel.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
updateSubtitleLabelAppearance()
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
topSubtitleLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor),
|
||||
topSubtitleLabel.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor, constant: 30),
|
||||
|
|
@ -671,7 +736,12 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
|
||||
func updateSubtitleLabelConstraints() {
|
||||
subtitleBottomConstraint?.constant = -subtitleBottomPadding
|
||||
if isControlsVisible {
|
||||
subtitleBottomToSliderConstraint?.constant = -20
|
||||
} else {
|
||||
subtitleBottomToSafeAreaConstraint?.constant = -subtitleBottomPadding
|
||||
}
|
||||
|
||||
view.setNeedsLayout()
|
||||
UIView.animate(withDuration: 0.2) {
|
||||
self.view.layoutIfNeeded()
|
||||
|
|
@ -783,6 +853,215 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
])
|
||||
}
|
||||
|
||||
private func updateSkipButtonsVisibility() {
|
||||
let t = currentTimeVal
|
||||
let controlsShowing = isControlsVisible // true ⇒ main UI is on‑screen
|
||||
|
||||
func handle(_ button: UIButton, range: CMTimeRange?) {
|
||||
guard let r = range else { button.isHidden = true; return }
|
||||
|
||||
let inInterval = t >= r.start.seconds && t <= r.end.seconds
|
||||
let target = controlsShowing ? 0.0 : skipButtonBaseAlpha
|
||||
|
||||
if inInterval {
|
||||
if button.isHidden {
|
||||
button.alpha = 0
|
||||
}
|
||||
button.isHidden = false
|
||||
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
button.alpha = target
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
guard !button.isHidden else { return }
|
||||
UIView.animate(withDuration: 0.15, animations: {
|
||||
button.alpha = 0
|
||||
}) { _ in
|
||||
button.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
handle(skipIntroButton, range: skipIntervals.op)
|
||||
handle(skipOutroButton, range: skipIntervals.ed)
|
||||
}
|
||||
|
||||
private func updateSegments() {
|
||||
sliderViewModel.introSegments.removeAll()
|
||||
sliderViewModel.outroSegments.removeAll()
|
||||
|
||||
if let op = skipIntervals.op {
|
||||
let start = max(0, op.start.seconds / duration)
|
||||
let end = min(1, op.end.seconds / duration)
|
||||
sliderViewModel.introSegments.append(start...end)
|
||||
}
|
||||
|
||||
if let ed = skipIntervals.ed {
|
||||
let start = max(0, ed.start.seconds / duration)
|
||||
let end = min(1, ed.end.seconds / duration)
|
||||
sliderViewModel.outroSegments.append(start...end)
|
||||
}
|
||||
|
||||
let segmentsColor = self.getSegmentsColor()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.sliderHostingController?.rootView = MusicProgressSlider(
|
||||
value: Binding(
|
||||
get: { max(0, min(self.sliderViewModel.sliderValue, self.duration)) }, // Remove extra ')'
|
||||
set: { self.sliderViewModel.sliderValue = max(0, min($0, self.duration)) } // Remove extra ')'
|
||||
),
|
||||
inRange: 0...(self.duration > 0 ? self.duration : 1.0),
|
||||
activeFillColor: .white,
|
||||
fillColor: .white.opacity(0.6),
|
||||
textColor: .white.opacity(0.7),
|
||||
emptyColor: .white.opacity(0.3),
|
||||
height: 33,
|
||||
onEditingChanged: { editing in
|
||||
if !editing {
|
||||
let targetTime = CMTime(
|
||||
seconds: self.sliderViewModel.sliderValue,
|
||||
preferredTimescale: 600
|
||||
)
|
||||
self.player.seek(to: targetTime)
|
||||
}
|
||||
},
|
||||
introSegments: self.sliderViewModel.introSegments,
|
||||
outroSegments: self.sliderViewModel.outroSegments,
|
||||
introColor: segmentsColor, // Match your color choices
|
||||
outroColor: segmentsColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private func fetchSkipTimes(type: String) {
|
||||
guard let mal = malID else { return }
|
||||
let url = URL(string: "https://api.aniskip.com/v2/skip-times/\(mal)/\(episodeNumber)?types=\(type)&episodeLength=0")!
|
||||
URLSession.shared.dataTask(with: url) { data, _, _ in
|
||||
guard let d = data,
|
||||
let resp = try? JSONDecoder().decode(AniSkipResponse.self, from: d),
|
||||
resp.found,
|
||||
let interval = resp.results.first?.interval else { return }
|
||||
|
||||
let range = CMTimeRange(
|
||||
start: CMTime(seconds: interval.startTime, preferredTimescale: 600),
|
||||
end: CMTime(seconds: interval.endTime, preferredTimescale: 600)
|
||||
)
|
||||
DispatchQueue.main.async {
|
||||
if type == "op" {
|
||||
self.skipIntervals.op = range
|
||||
} else {
|
||||
self.skipIntervals.ed = range
|
||||
}
|
||||
// Update segments only if duration is available
|
||||
if self.duration > 0 {
|
||||
self.updateSegments()
|
||||
}
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
|
||||
private func setupSkipButtons() {
|
||||
let introConfig = UIImage.SymbolConfiguration(pointSize: 14, weight: .bold)
|
||||
let introImage = UIImage(systemName: "forward.frame", withConfiguration: introConfig)
|
||||
|
||||
skipIntroButton = UIButton(type: .system)
|
||||
skipIntroButton.setImage(introImage, for: .normal)
|
||||
skipIntroButton.setTitle(" Skip Intro", for: .normal)
|
||||
skipIntroButton.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .bold)
|
||||
|
||||
// match skip85Button styling:
|
||||
skipIntroButton.backgroundColor = UIColor(red: 51/255, green: 51/255, blue: 51/255, alpha: 0.8)
|
||||
skipIntroButton.tintColor = .white
|
||||
skipIntroButton.setTitleColor(.white, for: .normal)
|
||||
skipIntroButton.layer.cornerRadius = 15
|
||||
skipIntroButton.alpha = skipButtonBaseAlpha
|
||||
skipIntroButton.contentEdgeInsets = UIEdgeInsets(top: 6, left: 10, bottom: 6, right: 10)
|
||||
skipIntroButton.layer.shadowColor = UIColor.black.cgColor
|
||||
skipIntroButton.layer.shadowOffset = CGSize(width: 0, height: 2)
|
||||
skipIntroButton.layer.shadowOpacity = 0.6
|
||||
skipIntroButton.layer.shadowRadius = 4
|
||||
skipIntroButton.layer.masksToBounds = false
|
||||
|
||||
skipIntroButton.addTarget(self, action: #selector(skipIntro), for: .touchUpInside)
|
||||
view.addSubview(skipIntroButton)
|
||||
skipIntroButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
skipIntroButton.leadingAnchor.constraint(
|
||||
equalTo: sliderHostingController!.view.leadingAnchor),
|
||||
skipIntroButton.bottomAnchor.constraint(
|
||||
equalTo: sliderHostingController!.view.topAnchor, constant: -5)
|
||||
])
|
||||
|
||||
// MARK: – Skip Outro Button
|
||||
let outroConfig = UIImage.SymbolConfiguration(pointSize: 14, weight: .bold)
|
||||
let outroImage = UIImage(systemName: "forward.frame", withConfiguration: outroConfig)
|
||||
|
||||
skipOutroButton = UIButton(type: .system)
|
||||
skipOutroButton.setImage(outroImage, for: .normal)
|
||||
skipOutroButton.setTitle(" Skip Outro", for: .normal)
|
||||
skipOutroButton.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .bold)
|
||||
|
||||
// same styling as above
|
||||
skipOutroButton.backgroundColor = skipIntroButton.backgroundColor
|
||||
skipOutroButton.tintColor = skipIntroButton.tintColor
|
||||
skipOutroButton.setTitleColor(.white, for: .normal)
|
||||
skipOutroButton.layer.cornerRadius = skipIntroButton.layer.cornerRadius
|
||||
skipOutroButton.alpha = skipIntroButton.alpha
|
||||
skipOutroButton.contentEdgeInsets = skipIntroButton.contentEdgeInsets
|
||||
skipOutroButton.layer.shadowColor = skipIntroButton.layer.shadowColor
|
||||
skipOutroButton.layer.shadowOffset = skipIntroButton.layer.shadowOffset
|
||||
skipOutroButton.layer.shadowOpacity = skipIntroButton.layer.shadowOpacity
|
||||
skipOutroButton.layer.shadowRadius = skipIntroButton.layer.shadowRadius
|
||||
skipOutroButton.layer.masksToBounds = false
|
||||
|
||||
skipOutroButton.addTarget(self, action: #selector(skipOutro), for: .touchUpInside)
|
||||
view.addSubview(skipOutroButton)
|
||||
skipOutroButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
skipOutroButton.leadingAnchor.constraint(
|
||||
equalTo: sliderHostingController!.view.leadingAnchor),
|
||||
skipOutroButton.bottomAnchor.constraint(
|
||||
equalTo: sliderHostingController!.view.topAnchor, constant: -5)
|
||||
])
|
||||
|
||||
view.bringSubviewToFront(skipOutroButton)
|
||||
}
|
||||
|
||||
private func setupDimButton() {
|
||||
let cfg = UIImage.SymbolConfiguration(pointSize: 24, weight: .regular)
|
||||
dimButton = UIButton(type: .system)
|
||||
dimButton.setImage(UIImage(systemName: "moon.fill", withConfiguration: cfg), for: .normal)
|
||||
dimButton.tintColor = .white
|
||||
dimButton.addTarget(self, action: #selector(dimTapped), for: .touchUpInside)
|
||||
controlsContainerView.addSubview(dimButton)
|
||||
dimButton.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
dimButton.layer.shadowColor = UIColor.black.cgColor
|
||||
dimButton.layer.shadowOffset = CGSize(width: 0, height: 2)
|
||||
dimButton.layer.shadowOpacity = 0.6
|
||||
dimButton.layer.shadowRadius = 4
|
||||
dimButton.layer.masksToBounds = false
|
||||
|
||||
NSLayoutConstraint.activate([
|
||||
dimButton.centerYAnchor.constraint(equalTo: dismissButton.centerYAnchor),
|
||||
dimButton.widthAnchor.constraint(equalToConstant: 24),
|
||||
dimButton.heightAnchor.constraint(equalToConstant: 24),
|
||||
])
|
||||
|
||||
dimButtonToSlider = dimButton.trailingAnchor.constraint(
|
||||
equalTo: volumeSliderHostingView!.leadingAnchor,
|
||||
constant: -8
|
||||
)
|
||||
dimButtonToRight = dimButton.trailingAnchor.constraint(
|
||||
equalTo: controlsContainerView.trailingAnchor,
|
||||
constant: -16
|
||||
)
|
||||
|
||||
dimButtonToSlider.isActive = true
|
||||
}
|
||||
|
||||
func updateMarqueeConstraints() {
|
||||
UIView.performWithoutAnimation {
|
||||
|
|
@ -790,13 +1069,13 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
|
||||
let leftSpacing: CGFloat = 2
|
||||
let rightSpacing: CGFloat = 6
|
||||
let trailingAnchor: NSLayoutXAxisAnchor = (volumeSliderHostingView?.isHidden == false)
|
||||
? volumeSliderHostingView!.leadingAnchor
|
||||
: view.safeAreaLayoutGuide.trailingAnchor
|
||||
let trailingAnchor: NSLayoutXAxisAnchor = dimButton.leadingAnchor
|
||||
|
||||
currentMarqueeConstraints = [
|
||||
marqueeLabel.leadingAnchor.constraint(equalTo: dismissButton.trailingAnchor, constant: leftSpacing),
|
||||
marqueeLabel.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -rightSpacing - 10),
|
||||
marqueeLabel.leadingAnchor.constraint(
|
||||
equalTo: dismissButton.trailingAnchor, constant: leftSpacing),
|
||||
marqueeLabel.trailingAnchor.constraint(
|
||||
equalTo: trailingAnchor, constant: -rightSpacing - 10),
|
||||
marqueeLabel.centerYAnchor.constraint(equalTo: dismissButton.centerYAnchor)
|
||||
]
|
||||
NSLayoutConstraint.activate(currentMarqueeConstraints)
|
||||
|
|
@ -956,25 +1235,31 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
|
||||
func updateSubtitleLabelAppearance() {
|
||||
// subtitleLabel always exists here:
|
||||
subtitleLabel.font = UIFont.systemFont(ofSize: CGFloat(subtitleFontSize))
|
||||
subtitleLabel.textColor = subtitleUIColor()
|
||||
subtitleLabel.backgroundColor = subtitleBackgroundEnabled ? UIColor.black.withAlphaComponent(0.6) : .clear
|
||||
subtitleLabel.backgroundColor = subtitleBackgroundEnabled
|
||||
? UIColor.black.withAlphaComponent(0.6)
|
||||
: .clear
|
||||
subtitleLabel.layer.cornerRadius = 5
|
||||
subtitleLabel.clipsToBounds = true
|
||||
subtitleLabel.layer.shadowColor = UIColor.black.cgColor
|
||||
subtitleLabel.layer.shadowRadius = CGFloat(subtitleShadowRadius)
|
||||
subtitleLabel.layer.shadowOpacity = 1.0
|
||||
subtitleLabel.layer.shadowOffset = CGSize.zero
|
||||
subtitleLabel.layer.shadowOffset = .zero
|
||||
|
||||
topSubtitleLabel.font = UIFont.systemFont(ofSize: CGFloat(subtitleFontSize))
|
||||
topSubtitleLabel.textColor = subtitleUIColor()
|
||||
topSubtitleLabel.backgroundColor = subtitleBackgroundEnabled ? UIColor.black.withAlphaComponent(0.6) : .clear
|
||||
topSubtitleLabel.layer.cornerRadius = 5
|
||||
topSubtitleLabel.clipsToBounds = true
|
||||
topSubtitleLabel.layer.shadowColor = UIColor.black.cgColor
|
||||
topSubtitleLabel.layer.shadowRadius = CGFloat(subtitleShadowRadius)
|
||||
topSubtitleLabel.layer.shadowOpacity = 1.0
|
||||
topSubtitleLabel.layer.shadowOffset = CGSize.zero
|
||||
// only style it if it’s been created already
|
||||
topSubtitleLabel?.font = UIFont.systemFont(ofSize: CGFloat(subtitleFontSize))
|
||||
topSubtitleLabel?.textColor = subtitleUIColor()
|
||||
topSubtitleLabel?.backgroundColor = subtitleBackgroundEnabled
|
||||
? UIColor.black.withAlphaComponent(0.6)
|
||||
: .clear
|
||||
topSubtitleLabel?.layer.cornerRadius = 5
|
||||
topSubtitleLabel?.clipsToBounds = true
|
||||
topSubtitleLabel?.layer.shadowColor = UIColor.black.cgColor
|
||||
topSubtitleLabel?.layer.shadowRadius = CGFloat(subtitleShadowRadius)
|
||||
topSubtitleLabel?.layer.shadowOpacity = 1.0
|
||||
topSubtitleLabel?.layer.shadowOffset = .zero
|
||||
}
|
||||
|
||||
func subtitleUIColor() -> UIColor {
|
||||
|
|
@ -1003,6 +1288,7 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
|
||||
self.currentTimeVal = time.seconds
|
||||
self.duration = currentDuration
|
||||
self.updateSegments()
|
||||
|
||||
if !self.isSliderEditing {
|
||||
self.sliderViewModel.sliderValue = max(0, min(self.currentTimeVal, self.duration))
|
||||
|
|
@ -1034,6 +1320,10 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
self.topSubtitleLabel.isHidden = true
|
||||
}
|
||||
|
||||
let current = self.currentTimeVal
|
||||
|
||||
let segmentsColor = self.getSegmentsColor()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
if let currentItem = self.player.currentItem, currentItem.duration.seconds > 0 {
|
||||
let progress = min(max(self.currentTimeVal / self.duration, 0), 1.0)
|
||||
|
|
@ -1085,12 +1375,31 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
)
|
||||
self.player.seek(to: targetTime)
|
||||
}
|
||||
}
|
||||
},
|
||||
introSegments: self.sliderViewModel.introSegments,
|
||||
outroSegments: self.sliderViewModel.outroSegments,
|
||||
introColor: segmentsColor, // Match your color choices
|
||||
outroColor: segmentsColor
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func skipIntro() {
|
||||
if let range = skipIntervals.op {
|
||||
player.seek(to: range.end)
|
||||
// optionally hide button immediately:
|
||||
skipIntroButton.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func skipOutro() {
|
||||
if let range = skipIntervals.ed {
|
||||
player.seek(to: range.end)
|
||||
skipOutroButton.isHidden = true
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func startUpdateTimer() {
|
||||
updateTimer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { [weak self] _ in
|
||||
|
|
@ -1113,18 +1422,35 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
anchor = controlsContainerView.trailingAnchor
|
||||
}
|
||||
|
||||
// rebuild & activate
|
||||
currentMenuButtonTrailing = menuButton.trailingAnchor.constraint(equalTo: anchor, constant: -6)
|
||||
currentMenuButtonTrailing.isActive = true
|
||||
}
|
||||
|
||||
@objc func toggleControls() {
|
||||
if isDimmed {
|
||||
dimButton.isHidden = false
|
||||
dimButton.alpha = 1.0
|
||||
dimButtonTimer?.invalidate()
|
||||
dimButtonTimer = Timer.scheduledTimer(withTimeInterval: 3.0, repeats: false) { [weak self] _ in
|
||||
guard let self = self else { return }
|
||||
UIView.animate(withDuration: 0.3, delay: 0, options: [.curveEaseInOut]) {
|
||||
self.dimButton.alpha = 0
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isControlsVisible.toggle()
|
||||
UIView.animate(withDuration: 0.2, delay: 0, options: .curveEaseInOut, animations: {
|
||||
let alphaVal: CGFloat = self.isControlsVisible ? 1 : 0
|
||||
self.controlsContainerView.alpha = alphaVal
|
||||
self.skip85Button.alpha = alphaVal
|
||||
})
|
||||
UIView.animate(withDuration: 0.2) {
|
||||
let a: CGFloat = self.isControlsVisible ? 1 : 0
|
||||
self.controlsContainerView.alpha = a
|
||||
self.skip85Button.alpha = a
|
||||
|
||||
self.subtitleBottomToSafeAreaConstraint?.isActive = !self.isControlsVisible
|
||||
self.subtitleBottomToSliderConstraint?.isActive = self.isControlsVisible
|
||||
|
||||
self.view.layoutIfNeeded()
|
||||
}
|
||||
self.updateSkipButtonsVisibility()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func seekBackwardLongPress(_ gesture: UILongPressGestureRecognizer) {
|
||||
|
|
@ -1191,19 +1517,16 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
isPlaying = false
|
||||
playPauseButton.image = UIImage(systemName: "play.fill")
|
||||
|
||||
// Defer the UI animation so that it doesn't block the pause call
|
||||
DispatchQueue.main.async {
|
||||
if !self.isControlsVisible {
|
||||
self.isControlsVisible = true
|
||||
UIView.animate(withDuration: 0.1, animations: {
|
||||
self.controlsContainerView.alpha = 1.0
|
||||
self.skip85Button.alpha = 0.8
|
||||
// Removed layoutIfNeeded() to avoid forcing a layout pass here
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Play immediately
|
||||
player.play()
|
||||
isPlaying = true
|
||||
playPauseButton.image = UIImage(systemName: "pause.fill")
|
||||
|
|
@ -1234,6 +1557,30 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele
|
|||
}
|
||||
}
|
||||
|
||||
@objc private func dimTapped() {
|
||||
isDimmed.toggle()
|
||||
dimButtonTimer?.invalidate()
|
||||
|
||||
// animate black overlay
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
self.blackCoverView.alpha = self.isDimmed ? 1.0 : 0.4
|
||||
}
|
||||
|
||||
// fade controls instead of hiding
|
||||
UIView.animate(withDuration: 0.25) {
|
||||
for view in self.controlsToHide {
|
||||
view.alpha = self.isDimmed ? 0 : 1
|
||||
}
|
||||
// keep the dim button visible/in front
|
||||
self.dimButton.alpha = self.isDimmed ? 0 : 1
|
||||
}
|
||||
|
||||
// swap your trailing constraints on the dim‑button
|
||||
dimButtonToSlider.isActive = !isDimmed
|
||||
dimButtonToRight.isActive = isDimmed
|
||||
UIView.animate(withDuration: 0.25) { self.view.layoutIfNeeded() }
|
||||
}
|
||||
|
||||
func speedChangerMenu() -> UIMenu {
|
||||
let speeds: [Double] = [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
|
||||
let playbackSpeedActions = speeds.map { speed in
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ class iCloudSyncManager {
|
|||
|
||||
func syncModulesFromiCloud() {
|
||||
guard let iCloudURL = self.ubiquityContainerURL else {
|
||||
Logger.shared.log("iCloud container not available", type: "Warning")
|
||||
Logger.shared.log("iCloud container not available", type: "Error")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,13 +92,9 @@ struct EpisodeCell: View {
|
|||
}
|
||||
.onAppear {
|
||||
updateProgress()
|
||||
|
||||
if UserDefaults.standard.object(forKey: "fetchEpisodeMetadata") == nil
|
||||
|| UserDefaults.standard.bool(forKey: "fetchEpisodeMetadata") {
|
||||
fetchEpisodeDetails()
|
||||
}
|
||||
}
|
||||
.onChange(of: progress) { newProgress in
|
||||
.onChange(of: progress) { _ in
|
||||
updateProgress()
|
||||
}
|
||||
.onTapGesture {
|
||||
|
|
@ -147,16 +143,12 @@ struct EpisodeCell: View {
|
|||
URLSession.custom.dataTask(with: url) { data, _, error in
|
||||
if let error = error {
|
||||
Logger.shared.log("Failed to fetch anime episode details: \(error)", type: "Error")
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
}
|
||||
DispatchQueue.main.async { self.isLoading = false }
|
||||
return
|
||||
}
|
||||
|
||||
guard let data = data else {
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
}
|
||||
DispatchQueue.main.async { self.isLoading = false }
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -168,21 +160,20 @@ struct EpisodeCell: View {
|
|||
let title = episodeDetails["title"] as? [String: String],
|
||||
let image = episodeDetails["image"] as? String else {
|
||||
Logger.shared.log("Invalid anime response format", type: "Error")
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
}
|
||||
DispatchQueue.main.async { self.isLoading = false }
|
||||
return
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
if UserDefaults.standard.object(forKey: "fetchEpisodeMetadata") == nil
|
||||
|| UserDefaults.standard.bool(forKey: "fetchEpisodeMetadata") {
|
||||
self.episodeTitle = title["en"] ?? ""
|
||||
self.episodeImageUrl = image
|
||||
self.isLoading = false
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
DispatchQueue.main.async {
|
||||
self.isLoading = false
|
||||
}
|
||||
DispatchQueue.main.async { self.isLoading = false }
|
||||
}
|
||||
}.resume()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,12 +52,18 @@ struct MediaInfoView: View {
|
|||
@State private var selectedRange: Range<Int> = 0..<100
|
||||
@State private var showSettingsMenu = false
|
||||
@State private var customAniListID: Int?
|
||||
@State private var showStreamLoadingView: Bool = false
|
||||
@State private var currentStreamTitle: String = ""
|
||||
|
||||
@State private var activeFetchID: UUID? = nil
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
|
||||
private var isGroupedBySeasons: Bool {
|
||||
return groupedEpisodes().count > 1
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Group {
|
||||
if isLoading {
|
||||
ProgressView()
|
||||
|
|
@ -444,6 +450,62 @@ struct MediaInfoView: View {
|
|||
}
|
||||
selectedRange = 0..<episodeChunkSize
|
||||
}
|
||||
|
||||
if showStreamLoadingView {
|
||||
VStack(spacing: 16) {
|
||||
Text("Loading \(currentStreamTitle)…")
|
||||
.font(.headline)
|
||||
.foregroundColor(.primary)
|
||||
|
||||
Button("Cancel") {
|
||||
withAnimation(.spring(response: 0.4, dampingFraction: 0.6)) {
|
||||
activeFetchID = nil
|
||||
isFetchingEpisode = false
|
||||
showStreamLoadingView = false
|
||||
}
|
||||
}
|
||||
.font(.subheadline)
|
||||
.padding(.vertical, 8)
|
||||
.padding(.horizontal, 24)
|
||||
.background(
|
||||
// Hex #FF705E
|
||||
Color(red: 1.0, green: 112/255.0, blue: 94/255.0)
|
||||
)
|
||||
.foregroundColor(.white)
|
||||
.cornerRadius(8)
|
||||
}
|
||||
.padding(.top, 20)
|
||||
.padding(.bottom, 16)
|
||||
.padding(.horizontal, 40)
|
||||
.background(.ultraThinMaterial)
|
||||
.cornerRadius(16)
|
||||
.shadow(color: Color.black.opacity(0.3), radius: 12, x: 0, y: 8)
|
||||
.frame(maxWidth: 300)
|
||||
.transition(.scale.combined(with: .opacity))
|
||||
.animation(.spring(response: 0.4, dampingFraction: 0.6), value: showStreamLoadingView)
|
||||
}
|
||||
}
|
||||
.navigationBarBackButtonHidden(true)
|
||||
.toolbar {
|
||||
ToolbarItem(placement: .navigationBarLeading) {
|
||||
Button(action: {
|
||||
activeFetchID = nil
|
||||
isFetchingEpisode = false
|
||||
showStreamLoadingView = false
|
||||
dismiss()
|
||||
}) {
|
||||
HStack {
|
||||
Image(systemName: "chevron.left")
|
||||
Text("Search")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.onDisappear {
|
||||
activeFetchID = nil
|
||||
isFetchingEpisode = false
|
||||
showStreamLoadingView = false
|
||||
}
|
||||
}
|
||||
|
||||
private var startWatchingText: String {
|
||||
|
|
@ -573,7 +635,10 @@ struct MediaInfoView: View {
|
|||
}
|
||||
|
||||
func fetchStream(href: String) {
|
||||
DropManager.shared.showDrop(title: "Fetching Stream", subtitle: "", duration: 0.5, icon: UIImage(systemName: "arrow.triangle.2.circlepath"))
|
||||
let fetchID = UUID()
|
||||
activeFetchID = fetchID
|
||||
currentStreamTitle = "Episode \(selectedEpisodeNumber)"
|
||||
showStreamLoadingView = true
|
||||
isFetchingEpisode = true
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
Task {
|
||||
|
|
@ -584,6 +649,8 @@ struct MediaInfoView: View {
|
|||
if module.metadata.softsub == true {
|
||||
if module.metadata.asyncJS == true {
|
||||
jsController.fetchStreamUrlJS(episodeUrl: href, softsub: true, module: module) { result in
|
||||
guard self.activeFetchID == fetchID else { return }
|
||||
|
||||
if let streams = result.streams, !streams.isEmpty {
|
||||
if streams.count > 1 {
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first)
|
||||
|
|
@ -599,6 +666,8 @@ struct MediaInfoView: View {
|
|||
}
|
||||
} else if module.metadata.streamAsyncJS == true {
|
||||
jsController.fetchStreamUrlJSSecond(episodeUrl: href, softsub: true, module: module) { result in
|
||||
guard self.activeFetchID == fetchID else { return }
|
||||
|
||||
if let streams = result.streams, !streams.isEmpty {
|
||||
if streams.count > 1 {
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first)
|
||||
|
|
@ -614,6 +683,8 @@ struct MediaInfoView: View {
|
|||
}
|
||||
} else {
|
||||
jsController.fetchStreamUrl(episodeUrl: href, softsub: true, module: module) { result in
|
||||
guard self.activeFetchID == fetchID else { return }
|
||||
|
||||
if let streams = result.streams, !streams.isEmpty {
|
||||
if streams.count > 1 {
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first)
|
||||
|
|
@ -631,6 +702,8 @@ struct MediaInfoView: View {
|
|||
} else {
|
||||
if module.metadata.asyncJS == true {
|
||||
jsController.fetchStreamUrlJS(episodeUrl: href, module: module) { result in
|
||||
guard self.activeFetchID == fetchID else { return }
|
||||
|
||||
if let streams = result.streams, !streams.isEmpty {
|
||||
if streams.count > 1 {
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first)
|
||||
|
|
@ -646,6 +719,8 @@ struct MediaInfoView: View {
|
|||
}
|
||||
} else if module.metadata.streamAsyncJS == true {
|
||||
jsController.fetchStreamUrlJSSecond(episodeUrl: href, module: module) { result in
|
||||
guard self.activeFetchID == fetchID else { return }
|
||||
|
||||
if let streams = result.streams, !streams.isEmpty {
|
||||
if streams.count > 1 {
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first)
|
||||
|
|
@ -661,6 +736,8 @@ struct MediaInfoView: View {
|
|||
}
|
||||
} else {
|
||||
jsController.fetchStreamUrl(episodeUrl: href, module: module) { result in
|
||||
guard self.activeFetchID == fetchID else { return }
|
||||
|
||||
if let streams = result.streams, !streams.isEmpty {
|
||||
if streams.count > 1 {
|
||||
self.showStreamSelectionAlert(streams: streams, fullURL: href, subtitles: result.subtitles?.first)
|
||||
|
|
@ -687,6 +764,8 @@ struct MediaInfoView: View {
|
|||
}
|
||||
|
||||
func handleStreamFailure(error: Error? = nil) {
|
||||
self.isFetchingEpisode = false
|
||||
self.showStreamLoadingView = false
|
||||
if let error = error {
|
||||
Logger.shared.log("Error loading module: \(error)", type: "Error")
|
||||
AnalyticsManager.shared.sendEvent(event: "error", additionalData: ["error": error, "message": "Failed to fetch stream"])
|
||||
|
|
@ -698,6 +777,8 @@ struct MediaInfoView: View {
|
|||
}
|
||||
|
||||
func showStreamSelectionAlert(streams: [String], fullURL: String, subtitles: String? = nil) {
|
||||
self.isFetchingEpisode = false
|
||||
self.showStreamLoadingView = false
|
||||
DispatchQueue.main.async {
|
||||
let alert = UIAlertController(title: "Select Server", message: "Choose a server to play from", preferredStyle: .actionSheet)
|
||||
|
||||
|
|
@ -760,6 +841,8 @@ struct MediaInfoView: View {
|
|||
}
|
||||
|
||||
func playStream(url: String, fullURL: String, subtitles: String? = nil) {
|
||||
self.isFetchingEpisode = false
|
||||
self.showStreamLoadingView = false
|
||||
DispatchQueue.main.async {
|
||||
let externalPlayer = UserDefaults.standard.string(forKey: "externalPlayer") ?? "Sora"
|
||||
var scheme: String?
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ struct SearchItem: Identifiable {
|
|||
let href: String
|
||||
}
|
||||
|
||||
|
||||
struct SearchView: View {
|
||||
@AppStorage("selectedModuleId") private var selectedModuleId: String?
|
||||
@AppStorage("mediaColumnsPortrait") private var mediaColumnsPortrait: Int = 2
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ struct SettingsViewPlayer: View {
|
|||
@AppStorage("holdForPauseEnabled") private var holdForPauseEnabled = false
|
||||
@AppStorage("skip85Visible") private var skip85Visible: Bool = true
|
||||
@AppStorage("doubleTapSeekEnabled") private var doubleTapSeekEnabled: Bool = false
|
||||
|
||||
@AppStorage("skipIntroOutroVisible") private var skipIntroOutroVisible: Bool = true
|
||||
|
||||
private let mediaPlayers = ["Default", "VLC", "OutPlayer", "Infuse", "nPlayer", "Sora"]
|
||||
|
||||
|
|
@ -61,6 +61,28 @@ struct SettingsViewPlayer: View {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section(header: Text("Progress bar Marker Color")) {
|
||||
ColorPicker("Segments Color", selection: Binding(
|
||||
get: {
|
||||
if let data = UserDefaults.standard.data(forKey: "segmentsColorData"),
|
||||
let uiColor = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as? UIColor {
|
||||
return Color(uiColor)
|
||||
}
|
||||
return .yellow
|
||||
},
|
||||
set: { newColor in
|
||||
let uiColor = UIColor(newColor)
|
||||
if let data = try? NSKeyedArchiver.archivedData(
|
||||
withRootObject: uiColor,
|
||||
requiringSecureCoding: false
|
||||
) {
|
||||
UserDefaults.standard.set(data, forKey: "segmentsColorData")
|
||||
}
|
||||
}
|
||||
))
|
||||
}
|
||||
|
||||
Section(header: Text("Skip Settings"), footer : Text("Double tapping the screen on it's sides will skip with the short tap setting.")) {
|
||||
HStack {
|
||||
Text("Tap Skip:")
|
||||
|
|
@ -79,6 +101,9 @@ struct SettingsViewPlayer: View {
|
|||
|
||||
Toggle("Show Skip 85s Button", isOn: $skip85Visible)
|
||||
.tint(.accentColor)
|
||||
|
||||
Toggle("Show Skip Intro / Outro Buttons", isOn: $skipIntroOutroVisible)
|
||||
.tint(.accentColor)
|
||||
}
|
||||
SubtitleSettingsSection()
|
||||
}
|
||||
|
|
|
|||
BIN
public-build/Sulfur.ipa
Normal file
BIN
public-build/Sulfur.ipa
Normal file
Binary file not shown.
Loading…
Reference in a new issue