Skip to content

[BUG] [Android] Resume the player after fatal error by player.loadPlaylist(), Lockscreen controller won't recover #168

@desmondgong-mw

Description

@desmondgong-mw

Describe the bug
When recovering from a Source error on Android (e.g., due to network loss) by calling player.loadPlaylist(), playback resumes correctly, but the lock-screen / notification media controls (MediaSession metadata) do not recover. The lock-screen controller disappears.

To Reproduce

  1. Start playback of a stream (audio or video).
  2. Disable network to trigger a Source error.
  3. In onPlayerError, call player.loadPlaylist([playItem]) to reload the same stream.
 onPlayerError={(e) => {
    console.error('[JWWrapper] Native onError event received:', e?.nativeEvent)
    try {
      // Attempt recovery
      if (isPlayingRef.current) {
        // Android cannot recover from a fatal error, reload the player
        retryTimeoutRef.current = BackgroundTimer.setTimeout(() => {
          console.log('[JWWrapper] Attempting playback recovery after error at ', retryCountRef.current)
          retryCountRef.current += 1
          playerRef.current?.loadPlaylist?.(config.playlist)
        }, RETRY_TIMEOUT)
      }
    } catch (err) {
      console.error('[JWWrapper] Error in onError handler:', err)
    }
}}
  1. Wait for onPlayerReady and call player.play().
  2. Observe that playback resumes, but the lock-screen/notification controller does not update.

Expected behavior
After recovery with loadPlaylist, the JWPlayer Android SDK should rebind/update the MediaService and MediaSession, so that the lock-screen controller:
Appears again if it was dismissed, and shows the correct metadata (title, description, artwork) for the reloaded playlist item.

Screenshots / Visual evidence
If applicable, add screenshots or recordings to help explain your problem. (Required if reproduction is not 100% reliable)

Desktop (please complete the following information):
If you are having a build issue, we would like to know about your machine.

  • Result of npx react-native info

Device(s) affected

Additional context
We've also tried to remounting the player by changing the playerKey when retry:

<JWPlayer
    key={playerKey}
    ref={ref}
    style={{ flex: 1 }}
    config={config}
    onPlayerError={onPlayerError}
/>

It would recover the MediaSession, but will face the following error and app crashed:

android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.mediaworks.therock.beta/com.jwplayer.pub.api.background.MediaService

JWP Ticketing
To expedite resolution and maintain confidentiality, submit a JWP request in addition to this new Issue. A JWP request offers the following benefits:

  • Associates the Issue with your company
  • Permits securely share sensitive information related to the bug, request, or question
  • Enhances JWP's ability to track progress and provide timely updates
  • Enables you to track and manage multiple issues through a single platform
ℹ️ While Issues are valuable for open-source collaboration, a JWP request ensures that you will receive clear timelines and efficient support.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-groomingHas not been reviewed by codeowners for scope/validation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions