test presentation model

This commit is contained in:
Francesco 2025-06-03 14:49:45 +02:00
parent c59462f42d
commit 2a3c58adbd
3 changed files with 65 additions and 13 deletions

View file

@ -0,0 +1,39 @@
//
// 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) {
}
}

View file

@ -5,6 +5,7 @@
// Created by Francesco on 05/01/25.
//
import AVKit
import SwiftUI
import Kingfisher
import SafariServices
@ -44,6 +45,9 @@ 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
@ -135,6 +139,11 @@ struct MediaInfoView: View {
bodyContent
.navigationBarHidden(true)
.ignoresSafeArea(.container, edges: .top)
.fullScreenCover(isPresented: $isVideoPlayerPresented) {
if let playerView = videoPlayerView {
playerView
}
}
VStack {
HStack {
@ -1342,19 +1351,19 @@ struct MediaInfoView: View {
case "IINA":
scheme = "iina://weblink?url=\(url)"
case "Default":
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)
}
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
return
default:
break

View file

@ -80,6 +80,7 @@
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 */; };
@ -171,6 +172,7 @@
13EA2BD12D32D97400C1EBD7 /* CustomPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomPlayer.swift; sourceTree = "<group>"; };
13EA2BD32D32D97400C1EBD7 /* Double+Extension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Double+Extension.swift"; sourceTree = "<group>"; };
13EA2BD82D32D98400C1EBD7 /* NormalPlayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NormalPlayer.swift; sourceTree = "<group>"; };
13FB8D382DEF269F008C3920 /* VideoPlayerView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = VideoPlayerView.swift; sourceTree = "<group>"; };
1E26E9E62DA9577900B9DC02 /* VolumeSlider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VolumeSlider.swift; sourceTree = "<group>"; };
1E47859A2DEBC5960095BF2F /* AnilistMatchPopupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnilistMatchPopupView.swift; sourceTree = "<group>"; };
1E9FF1D22D403E42008AC100 /* SettingsViewLoggerFilter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsViewLoggerFilter.swift; sourceTree = "<group>"; };
@ -540,6 +542,7 @@
13EA2BD02D32D97400C1EBD7 /* CustomPlayer */,
13DC0C452D302C7500D0F966 /* VideoPlayer.swift */,
13EA2BD82D32D98400C1EBD7 /* NormalPlayer.swift */,
13FB8D382DEF269F008C3920 /* VideoPlayerView.swift */,
);
path = MediaPlayer;
sourceTree = "<group>";
@ -762,6 +765,7 @@
0457C59D2DE78267000AFBD9 /* BookmarkGridView.swift in Sources */,
0457C59E2DE78267000AFBD9 /* BookmarkLink.swift in Sources */,
0457C59F2DE78267000AFBD9 /* BookmarkGridItemView.swift in Sources */,
13FB8D392DEF269F008C3920 /* VideoPlayerView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};