File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
boringNotch/MediaControllers Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,9 @@ class SpotifyController: MediaControllerProtocol {
1717
1818 var playbackStatePublisher : Published < PlaybackState > . Publisher { $playbackState }
1919
20+ //Constant for time between command and update
21+ let commandUpdateDelay : Duration = . milliseconds( 25 )
22+
2023 init ( ) {
2124 setupPlaybackStateChangeObserver ( )
2225 DispatchQueue . main. async { [ weak self] in
@@ -67,17 +70,26 @@ class SpotifyController: MediaControllerProtocol {
6770
6871 func seek( to time: Double ) {
6972 executeCommand ( " set player position to \( time) " )
70- updatePlaybackInfo ( )
73+ Task {
74+ try ? await Task . sleep ( for: commandUpdateDelay)
75+ updatePlaybackInfo ( )
76+ }
7177 }
7278
7379 func toggleShuffle( ) {
7480 executeCommand ( " set shuffling to not shuffling " )
75- updatePlaybackInfo ( )
81+ Task {
82+ try ? await Task . sleep ( for: commandUpdateDelay)
83+ updatePlaybackInfo ( )
84+ }
7685 }
7786
7887 func toggleRepeat( ) {
7988 executeCommand ( " set repeating to not repeating " )
80- updatePlaybackInfo ( )
89+ Task {
90+ try ? await Task . sleep ( for: commandUpdateDelay)
91+ updatePlaybackInfo ( )
92+ }
8193 }
8294
8395 func isActive( ) -> Bool {
You can’t perform that action at this time.
0 commit comments