|
8 | 8 | import SwiftUI
|
9 | 9 |
|
10 | 10 | @MainActor
|
11 |
| -internal class PlayerErrorCoordinator: NSObject, PlayerErrorDelegate { |
| 11 | +internal class PlayerCoordinator: NSObject, PlayerErrorDelegate { |
12 | 12 |
|
| 13 | + /// Stores the last command applied to the player. |
| 14 | + private var lastCommand: PlaybackCommand? |
| 15 | + |
| 16 | + /// A binding to an optional `VPErrors` instance, used to report errors back to the parent view. |
13 | 17 | @Binding private var error: VPErrors?
|
14 | 18 |
|
| 19 | + /// Initializes a new instance of `PlayerCoordinator`. |
| 20 | + /// - Parameter error: A binding to an optional `VPErrors` instance to manage error reporting. |
15 | 21 | init(_ error: Binding<VPErrors?>) {
|
16 | 22 | self._error = error
|
17 | 23 | }
|
18 | 24 |
|
| 25 | + /// Deinitializes the coordinator and prints a debug message if in DEBUG mode. |
19 | 26 | deinit {
|
20 | 27 | #if DEBUG
|
21 | 28 | print("deinit Coordinator")
|
22 | 29 | #endif
|
23 | 30 | }
|
24 | 31 |
|
25 |
| - /// Handles receiving an error and updates the error state in the parent view |
26 |
| - /// - Parameter error: The error received |
| 32 | + /// Handles receiving an error and updates the error state in the parent view. |
| 33 | + /// This method is called when an error is encountered during playback or other operations. |
| 34 | + /// - Parameter error: The error received. |
27 | 35 | func didReceiveError(_ error: VPErrors) {
|
28 |
| - self.error = error |
| 36 | + self.error = error |
| 37 | + } |
| 38 | + |
| 39 | + /// Sets the last command applied to the player. |
| 40 | + /// This method updates the stored `lastCommand` to the provided value. |
| 41 | + /// - Parameter command: The `PlaybackCommand` that was last applied to the player. |
| 42 | + func setLastCommand(_ command: PlaybackCommand) { |
| 43 | + self.lastCommand = command |
| 44 | + } |
| 45 | + |
| 46 | + /// Retrieves the last command applied to the player. |
| 47 | + /// - Returns: The `PlaybackCommand` that was last applied to the player. |
| 48 | + var getLastCommand : PlaybackCommand? { |
| 49 | + return lastCommand |
29 | 50 | }
|
30 | 51 | }
|
0 commit comments