Skip to content

Commit

Permalink
uh idk
Browse files Browse the repository at this point in the history
  • Loading branch information
cranci1 committed Feb 2, 2025
1 parent 182244b commit 78ccc08
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct MusicProgressSlider<T: BinaryFloatingPoint>: View {
.mask({
HStack {
Rectangle()
.frame(width: max(bounds.size.width * CGFloat((localRealProgress + localTempProgress)), 0), alignment: .leading)
.frame(width: max((bounds.size.width * CGFloat(localRealProgress + localTempProgress)).isFinite ? bounds.size.width * CGFloat(localRealProgress + localTempProgress) : 0, 0), alignment: .leading)
Spacer(minLength: 0)
}
})
Expand Down
36 changes: 36 additions & 0 deletions Sora/Views/MediaInfoView/MediaInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ struct MediaInfoView: View {
@State var isRefetching: Bool = true
@State var isFetchingEpisode: Bool = false

@State private var selectedEpisode: String = ""
@State private var selectedEpisodeNumber: Int = 0

@AppStorage("externalPlayer") private var externalPlayer: String = "Default"
@AppStorage("episodeChunkSize") private var episodeChunkSize: Int = 100

Expand Down Expand Up @@ -384,6 +387,26 @@ struct MediaInfoView: View {
scheme = "outplayer://\(url)"
case "nPlayer":
scheme = "nplayer-\(url)"
case "Sora":
let customMediaPlayer = CustomMediaPlayer(
module: module,
urlString: url,
fullUrl: fullURL,
title: title,
episodeNumber: selectedEpisodeNumber,
onWatchNext: {
selectNextEpisode()
}
)
let hostingController = UIHostingController(rootView: customMediaPlayer)
hostingController.modalPresentationStyle = .fullScreen
Logger.shared.log("Opening custom media player with url: \(url)")

if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let rootVC = windowScene.windows.first?.rootViewController {
rootVC.present(hostingController, animated: true, completion: nil)
}
return
default:
break
}
Expand All @@ -404,6 +427,19 @@ struct MediaInfoView: View {
}
}
}

private func selectNextEpisode() {
guard let currentEpisodeIndex = episodeLinks.firstIndex(where: { $0.href == selectedEpisode }) else { return }
let nextEpisodeIndex = currentEpisodeIndex + 1
print(nextEpisodeIndex)
if nextEpisodeIndex < episodeLinks.count {
selectedEpisode = episodeLinks[nextEpisodeIndex].href
selectedEpisodeNumber = episodeLinks[nextEpisodeIndex].number
let nextEpisodeURL = episodeLinks[nextEpisodeIndex].href
fetchStream(href: nextEpisodeURL)
print(nextEpisodeURL)
}
}

private func openSafariViewController(with urlString: String) {
guard let url = URL(string: urlString) else {
Expand Down

0 comments on commit 78ccc08

Please sign in to comment.