oh lol it works
Some checks are pending
Build and Release IPA / Build IPA and Mac Catalyst (push) Waiting to run

This commit is contained in:
cranci1 2024-12-31 09:12:18 +01:00
parent 7cec64fc9a
commit bda1df0b84

View file

@ -107,6 +107,7 @@ struct MediaView: View {
HStack {
Button(action: {
startWatchingFirstUnfinishedEpisode()
}) {
HStack {
Image(systemName: "play.fill")
@ -224,6 +225,22 @@ struct MediaView: View {
}
}
private func startWatchingFirstUnfinishedEpisode() {
for (index, episode) in episodes.enumerated() {
let episodeURL = episode.hasPrefix("https") ? episode : "\(module.module[0].details.baseURL)\(episode)"
let totalTime = UserDefaults.standard.double(forKey: "totalTime_\(episodeURL)")
let lastPlayedTime = UserDefaults.standard.double(forKey: "lastPlayedTime_\(episodeURL)")
let progress = totalTime > 0 ? lastPlayedTime / totalTime : 0
if progress < 0.90 {
selectedEpisode = episode
selectedEpisodeNumber = index + 1
fetchEpisodeStream(urlString: episodeURL)
break
}
}
}
func playStream(urlString: String?, fullURL: String) {
guard let streamUrl = urlString else { return }