How to solve the problem that the progress status of the audio playback control notification bar does not update

Published: (February 27, 2026 at 02:46 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

Problem Description

When playing audio, the following situations occur after creating and setting the AVSessionManager session:

  • The progress in the notification bar does not update after setting the playback status.
  • Pulling down the notification bar restores normal updates.
  • Locking the screen and then unlocking also restores normal updates.

Background Knowledge

  • AVSession Kit – System‑provided audio and video control services that centrally manage all audio and video activities within the system.
  • Background Tasks Kit – Background task management. After an app transitions to the background, resources are strictly controlled. Apps should select appropriate background tasks to ensure continued operation.
  • Media Session Provider – Allows audio/video applications to control media‑related information from the media session controller and respond to playback control commands issued by the controller.

Troubleshooting Process

  • Verify that the long‑running task AUDIO_PLAYBACK has been applied.
  • Ensure that resource duration, playback status, playback position, speed, and other information are set correctly. The broadcast control center uses this data to display the progress.

Analysis Conclusion

An error in initializing the playback status in the broadcast control center caused the playback progress calculation to fail, so the progress bar did not update. Pulling down the status bar or locking/unlocking the screen forces the system to recalculate and display the correct progress.

Solution

1. Apply for a long‑duration task

Use BackgroundTasks Kit to request the AUDIO_PLAYBACK long‑duration task, preventing the app from entering the Suspend state.

backgroundTaskManager.startBackgroundRunning(
  this.context,
  backgroundTaskManager.BackgroundMode.AUDIO_PLAYBACK,
  wantAgentObj
).then(() => {
  console.info("Operation startBackgroundRunning succeeded");
}).catch((error: BusinessError) => {
  console.error(`Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`);
});

2. Initialize and update playback resources correctly

Set the playback state for the AVSession. The system will automatically calculate the progress based on the provided information; real‑time progress updates from the app are not required.

let playbackState: AVSessionManager.AVPlaybackState = {
  state: AVSessionManager.PlaybackState.PLAYBACK_STATE_PLAY,
  position: {
    elapsedTime: 1000,               // milliseconds elapsed since start
    updateTime: new Date().getTime() // timestamp of the update
  },
  speed: 1.0,
  bufferedTime: 14000               // buffered duration in milliseconds
};

session.setAVPlaybackState(playbackState, (err) => {
  if (err) {
    console.error(`Failed to set AVPlaybackState. Code: ${err.code}, message: ${err.message}`);
  } else {
    console.info(`SetAVPlaybackState successfully`);
  }
});

Notice

  • Update the AVPlaybackState only when the playback state, position, or speed changes; otherwise the system may produce calculation errors.
  • When playback starts, report the initial position. If the media is buffering, first set the state to AVSessionManager.PlaybackState.PLAYBACK_STATE_BUFFERING to tell the system not to refresh the progress bar.

Verification Result

The system’s playback control center now automatically calculates and refreshes the progress bar based on the playback state. The application only needs to update the state when the rate, position, or other relevant information changes.

0 views
Back to Blog

Related posts

Read more »