mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-20 16:12:50 +00:00
test GroupActivity
This commit is contained in:
parent
cc6a24d65c
commit
a4899f1196
1 changed files with 26 additions and 1 deletions
|
|
@ -33,6 +33,7 @@ class VideoPlayerViewController: UIViewController {
|
|||
|
||||
private var sharePlayCoordinator: SharePlayCoordinator?
|
||||
private var subscriptions = Set<AnyCancellable>()
|
||||
private var groupSessionObserver: AnyCancellable?
|
||||
|
||||
private var aniListUpdateSent = false
|
||||
private var aniListUpdatedSuccessfully = false
|
||||
|
|
@ -53,7 +54,7 @@ class VideoPlayerViewController: UIViewController {
|
|||
}
|
||||
|
||||
private func setupSubtitles() {
|
||||
guard !subtitles.isEmpty, UserDefaults.standard.bool(forKey: "subtitlesEnabled"), let subtitleURL = URL(string: subtitles) else {
|
||||
guard !subtitles.isEmpty, UserDefaults.standard.bool(forKey: "subtitlesEnabled"), let _ = URL(string: subtitles) else {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -151,6 +152,29 @@ class VideoPlayerViewController: UIViewController {
|
|||
} else {
|
||||
self.player?.play()
|
||||
}
|
||||
|
||||
observeGroupSession()
|
||||
}
|
||||
|
||||
private func observeGroupSession() {
|
||||
groupSessionObserver = nil
|
||||
Task { [weak self] in
|
||||
guard let self = self else { return }
|
||||
for await session in VideoWatchingActivity.sessions() {
|
||||
await self.handleIncomingGroupSession(session)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor
|
||||
private func handleIncomingGroupSession(_ session: GroupSession<VideoWatchingActivity>) async {
|
||||
if sharePlayCoordinator == nil {
|
||||
sharePlayCoordinator = SharePlayCoordinator()
|
||||
}
|
||||
sharePlayCoordinator?.configureGroupSession()
|
||||
if let player = self.player {
|
||||
sharePlayCoordinator?.coordinatePlayback(with: player)
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
|
|
@ -386,5 +410,6 @@ class VideoPlayerViewController: UIViewController {
|
|||
sharePlayCoordinator?.leaveGroupSession()
|
||||
sharePlayCoordinator = nil
|
||||
subscriptions.removeAll()
|
||||
groupSessionObserver = nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue