From 87a77d08f5f8bd8a6f356e7aba654d59955d63a3 Mon Sep 17 00:00:00 2001 From: Francesco <100066266+cranci1@users.noreply.github.com> Date: Tue, 3 Jun 2025 18:04:41 +0200 Subject: [PATCH] Revert "test presentation model" This reverts commit 2a3c58adbdb5dd33418338bcef818c2abcd24d05. --- Sora/Utils/MediaPlayer/VideoPlayerView.swift | 39 -------------------- Sora/Views/MediaInfoView/MediaInfoView.swift | 35 +++++++----------- Sulfur.xcodeproj/project.pbxproj | 4 -- 3 files changed, 13 insertions(+), 65 deletions(-) delete mode 100644 Sora/Utils/MediaPlayer/VideoPlayerView.swift diff --git a/Sora/Utils/MediaPlayer/VideoPlayerView.swift b/Sora/Utils/MediaPlayer/VideoPlayerView.swift deleted file mode 100644 index d8087e4..0000000 --- a/Sora/Utils/MediaPlayer/VideoPlayerView.swift +++ /dev/null @@ -1,39 +0,0 @@ -// -// VideoPlayerView.swift -// Sora -// -// Created by Francesco on 3/06/25. -// - -import SwiftUI -import AVKit - -struct VideoPlayerView: UIViewControllerRepresentable { - let module: ScrapingModule - var streamUrl: String? - var fullUrl: String - var subtitles: String - var aniListID: Int - var headers: [String:String]? - var totalEpisodes: Int - var episodeNumber: Int - var episodeImageUrl: String - var mediaTitle: String - - func makeUIViewController(context: Context) -> VideoPlayerViewController { - let controller = VideoPlayerViewController(module: module) - controller.streamUrl = streamUrl - controller.fullUrl = fullUrl - controller.subtitles = subtitles - controller.aniListID = aniListID - controller.headers = headers - controller.totalEpisodes = totalEpisodes - controller.episodeNumber = episodeNumber - controller.episodeImageUrl = episodeImageUrl - controller.mediaTitle = mediaTitle - return controller - } - - func updateUIViewController(_ uiViewController: VideoPlayerViewController, context: Context) { - } -} diff --git a/Sora/Views/MediaInfoView/MediaInfoView.swift b/Sora/Views/MediaInfoView/MediaInfoView.swift index e0a3c29..b020fcb 100644 --- a/Sora/Views/MediaInfoView/MediaInfoView.swift +++ b/Sora/Views/MediaInfoView/MediaInfoView.swift @@ -5,7 +5,6 @@ // Created by Francesco on 05/01/25. // -import AVKit import SwiftUI import Kingfisher import SafariServices @@ -45,9 +44,6 @@ struct MediaInfoView: View { @State private var selectedEpisodeImage: String = "" @State private var selectedSeason: Int = 0 - @State private var isVideoPlayerPresented: Bool = false - @State private var videoPlayerView: VideoPlayerView? - @AppStorage("externalPlayer") private var externalPlayer: String = "Default" @AppStorage("episodeChunkSize") private var episodeChunkSize: Int = 100 @@ -160,11 +156,6 @@ struct MediaInfoView: View { bodyContent .navigationBarHidden(true) .ignoresSafeArea(.container, edges: .top) - .fullScreenCover(isPresented: $isVideoPlayerPresented) { - if let playerView = videoPlayerView { - playerView - } - } VStack { HStack { @@ -1360,19 +1351,19 @@ struct MediaInfoView: View { case "IINA": scheme = "iina://weblink?url=\(url)" case "Default": - self.videoPlayerView = VideoPlayerView( - module: module, - streamUrl: url, - fullUrl: fullURL, - subtitles: subtitles ?? "", - aniListID: itemID ?? 0, - headers: headers, - totalEpisodes: episodeLinks.count, - episodeNumber: selectedEpisodeNumber, - episodeImageUrl: selectedEpisodeImage, - mediaTitle: title - ) - self.isVideoPlayerPresented = true + let videoPlayerViewController = VideoPlayerViewController(module: module) + videoPlayerViewController.headers = headers + videoPlayerViewController.streamUrl = url + videoPlayerViewController.fullUrl = fullURL + videoPlayerViewController.episodeNumber = selectedEpisodeNumber + videoPlayerViewController.episodeImageUrl = selectedEpisodeImage + videoPlayerViewController.mediaTitle = title + videoPlayerViewController.aniListID = itemID ?? 0 + videoPlayerViewController.modalPresentationStyle = .fullScreen + + if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene, let rootVC = windowScene.windows.first?.rootViewController { + rootVC.present(videoPlayerViewController, animated: true, completion: nil) + } return default: break diff --git a/Sulfur.xcodeproj/project.pbxproj b/Sulfur.xcodeproj/project.pbxproj index 90ec057..61d7e9c 100644 --- a/Sulfur.xcodeproj/project.pbxproj +++ b/Sulfur.xcodeproj/project.pbxproj @@ -80,7 +80,6 @@ 13EA2BD52D32D97400C1EBD7 /* CustomPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13EA2BD12D32D97400C1EBD7 /* CustomPlayer.swift */; }; 13EA2BD62D32D97400C1EBD7 /* Double+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13EA2BD32D32D97400C1EBD7 /* Double+Extension.swift */; }; 13EA2BD92D32D98400C1EBD7 /* NormalPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13EA2BD82D32D98400C1EBD7 /* NormalPlayer.swift */; }; - 13FB8D392DEF269F008C3920 /* VideoPlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13FB8D382DEF269F008C3920 /* VideoPlayerView.swift */; }; 1E26E9E72DA9577900B9DC02 /* VolumeSlider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E26E9E62DA9577900B9DC02 /* VolumeSlider.swift */; }; 1E47859B2DEBC5960095BF2F /* AnilistMatchPopupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E47859A2DEBC5960095BF2F /* AnilistMatchPopupView.swift */; }; 1E9FF1D32D403E49008AC100 /* SettingsViewLoggerFilter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E9FF1D22D403E42008AC100 /* SettingsViewLoggerFilter.swift */; }; @@ -172,7 +171,6 @@ 13EA2BD12D32D97400C1EBD7 /* CustomPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomPlayer.swift; sourceTree = ""; }; 13EA2BD32D32D97400C1EBD7 /* Double+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Double+Extension.swift"; sourceTree = ""; }; 13EA2BD82D32D98400C1EBD7 /* NormalPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NormalPlayer.swift; sourceTree = ""; }; - 13FB8D382DEF269F008C3920 /* VideoPlayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoPlayerView.swift; sourceTree = ""; }; 1E26E9E62DA9577900B9DC02 /* VolumeSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VolumeSlider.swift; sourceTree = ""; }; 1E47859A2DEBC5960095BF2F /* AnilistMatchPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnilistMatchPopupView.swift; sourceTree = ""; }; 1E9FF1D22D403E42008AC100 /* SettingsViewLoggerFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewLoggerFilter.swift; sourceTree = ""; }; @@ -542,7 +540,6 @@ 13EA2BD02D32D97400C1EBD7 /* CustomPlayer */, 13DC0C452D302C7500D0F966 /* VideoPlayer.swift */, 13EA2BD82D32D98400C1EBD7 /* NormalPlayer.swift */, - 13FB8D382DEF269F008C3920 /* VideoPlayerView.swift */, ); path = MediaPlayer; sourceTree = ""; @@ -765,7 +762,6 @@ 0457C59D2DE78267000AFBD9 /* BookmarkGridView.swift in Sources */, 0457C59E2DE78267000AFBD9 /* BookmarkLink.swift in Sources */, 0457C59F2DE78267000AFBD9 /* BookmarkGridItemView.swift in Sources */, - 13FB8D392DEF269F008C3920 /* VideoPlayerView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };