Quellcode durchsuchen

fix(player): ensure controller fallback hits coordinator

onecold vor 4 Monaten
Ursprung
Commit
29e96d7653

+ 3 - 3
entry/src/main/ets/controller/MusicPlaybackController.ets

@@ -306,12 +306,12 @@ export class MusicPlaybackController {
     await this.playbackCoordinator.playPrevious()
     await this.playbackCoordinator.playPrevious()
   }
   }
 
 
-  public playOrPause(): void {
+  public async playOrPause(): Promise<void> {
     if (this.actions) {
     if (this.actions) {
-      this.actions.playOrPause()
+      await this.actions.playOrPause()
       return
       return
     }
     }
-    void this.playbackCoordinator.playOrPause()
+    await this.playbackCoordinator.playOrPause()
   }
   }
 
 
   public async playNext(): Promise<void> {
   public async playNext(): Promise<void> {

+ 2 - 0
entry/src/ohosTest/ets/test/List.test.ets

@@ -14,11 +14,13 @@
  */
  */
 
 
 import abilityTest from './Ability.test'
 import abilityTest from './Ability.test'
+import musicPlaybackControllerTest from './MusicPlaybackController.test'
 import playbackCoordinatorTest from './PlaybackCoordinator.test'
 import playbackCoordinatorTest from './PlaybackCoordinator.test'
 import playbackStateBridgeTest from './PlaybackStateBridge.test'
 import playbackStateBridgeTest from './PlaybackStateBridge.test'
 
 
 export default function testsuite() {
 export default function testsuite() {
   abilityTest()
   abilityTest()
+  musicPlaybackControllerTest()
   playbackCoordinatorTest()
   playbackCoordinatorTest()
   playbackStateBridgeTest()
   playbackStateBridgeTest()
 }
 }

+ 4 - 4
entry/src/ohosTest/ets/test/MusicPlaybackController.test.ets

@@ -35,7 +35,7 @@ export default function musicPlaybackControllerTest() {
       })
       })
 
 
       await controller.playQueue(songs, 1, 'charts-count')
       await controller.playQueue(songs, 1, 'charts-count')
-      await controller.playOrPauseDirect()
+      await controller.playOrPause()
       await controller.seekTo('88', 'controller-test')
       await controller.seekTo('88', 'controller-test')
 
 
       expect(calls.join(',')).assertEqual('playQueue:1:charts-count,playOrPause,seekTo:88:controller-test')
       expect(calls.join(',')).assertEqual('playQueue:1:charts-count,playOrPause,seekTo:88:controller-test')
@@ -65,7 +65,7 @@ export default function musicPlaybackControllerTest() {
         }
         }
       })
       })
 
 
-      controller.playOrPause()
+      await controller.playOrPause()
       await controller.playNext()
       await controller.playNext()
       await controller.playPrevious()
       await controller.playPrevious()
       await controller.setLoopMode()
       await controller.setLoopMode()
@@ -101,7 +101,7 @@ export default function musicPlaybackControllerTest() {
       controller.setActions(actions)
       controller.setActions(actions)
       controller.clearActions(actions)
       controller.clearActions(actions)
 
 
-      controller.playOrPause()
+      await controller.playOrPause()
       await controller.playNext()
       await controller.playNext()
       await controller.seekTo('1', 'cleared')
       await controller.seekTo('1', 'cleared')
 
 
@@ -113,7 +113,7 @@ export default function musicPlaybackControllerTest() {
       const controller = MusicPlaybackController.getInstance()
       const controller = MusicPlaybackController.getInstance()
 
 
       controller.clearActions()
       controller.clearActions()
-      controller.playOrPause()
+      await controller.playOrPause()
       await controller.playNext()
       await controller.playNext()
       await controller.playPrevious()
       await controller.playPrevious()
       await controller.setLoopMode()
       await controller.setLoopMode()