You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-2Lines changed: 12 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,15 +170,15 @@ To ensure .play is applied before .pause, you can use `Task` to schedule the sec
170
170
```swift
171
171
playbackCommand = .play
172
172
173
-
Task { @MainActor
173
+
Task { @MainActorin
174
174
playbackCommand = .pause
175
175
Task { playbackCommand = .play } // This runs AFTER `.pause`
176
176
}
177
177
```
178
178
179
179
### Handling Sequential Similar Commands
180
180
181
-
When using the video player controls in your SwiftUI application, it's important to understand how command processing works. Specifically, issuing two identical commands consecutively will result in the second command being ignored. This is due to the underlying implementation in SwiftUI that prevents redundant command execution to optimize performance and user experience.
181
+
When using the video player controls in your SwiftUI application, it's important to understand how command processing works. Specifically, issuing two identical commands consecutively will result in the second command being ignored. This is due to the underlying implementation that prevents redundant command execution to optimize performance and user experience in terms of UI updates.
182
182
183
183
### Common Scenario
184
184
@@ -188,6 +188,16 @@ For example, if you attempt to pause the video player twice in a row, the second
188
188
189
189
In cases where you need to re-issue a command that might appear redundant but is necessary under specific conditions, you must insert an `idle` command between the two similar commands. The `idle` command resets the command state of the player, allowing subsequent commands to be processed as new actions.
190
190
191
+
**.play → .idle → .play**
192
+
193
+
```swift
194
+
playbackCommand = .play
195
+
196
+
Task { @MainActorin
197
+
playbackCommand = .idle
198
+
Task { playbackCommand = .play } // This runs AFTER `.idle`
0 commit comments