ref |> 处理音频播控中心暂停后再播放问题
Signed-off-by: xugenyuan <xugenyuan@wondertek.com.cn>
Showing
2 changed files
with
16 additions
and
1 deletions
| @@ -224,7 +224,7 @@ export class BackgroundAudioController { | @@ -224,7 +224,7 @@ export class BackgroundAudioController { | ||
| 224 | listenPlayEvents() { | 224 | listenPlayEvents() { |
| 225 | this.lastSession?.on('play', () => { | 225 | this.lastSession?.on('play', () => { |
| 226 | Logger.debug(TAG, `on play `); | 226 | Logger.debug(TAG, `on play `); |
| 227 | - this.avplayerController?.play() | 227 | + this.avplayerController?.resume() |
| 228 | this.hasSetupProgress = false | 228 | this.hasSetupProgress = false |
| 229 | }); | 229 | }); |
| 230 | this.lastSession?.on('pause', () => { | 230 | this.lastSession?.on('pause', () => { |
| @@ -249,6 +249,21 @@ export class WDPlayerController { | @@ -249,6 +249,21 @@ export class WDPlayerController { | ||
| 249 | this.avPlayer?.pause(); | 249 | this.avPlayer?.pause(); |
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | + async resume() { | ||
| 253 | + if (this.status == PlayerConstants.STATUS_PAUSE) { | ||
| 254 | + Logger.debug(TAG, "start resume") | ||
| 255 | + this.avPlayer?.play(); | ||
| 256 | + return | ||
| 257 | + } | ||
| 258 | + if (this.status == PlayerConstants.STATUS_COMPLETION) { | ||
| 259 | + Logger.debug(TAG, "start resume") | ||
| 260 | + this.avPlayer?.seek(0); | ||
| 261 | + this.avPlayer?.play(); | ||
| 262 | + return | ||
| 263 | + } | ||
| 264 | + this.play() | ||
| 265 | + } | ||
| 266 | + | ||
| 252 | async play() { | 267 | async play() { |
| 253 | // if (this.avPlayer == null) { | 268 | // if (this.avPlayer == null) { |
| 254 | // await this.initPromise; | 269 | // await this.initPromise; |
-
Please register or login to post a comment