Skip to content

fix(player): fix returning playback position to external apps (Lampa, etc.) - #1846

Open
arabianq wants to merge 2 commits into
anilbeesetti:mainfrom
arabianq:fix/lampa-position
Open

fix(player): fix returning playback position to external apps (Lampa, etc.)#1846
arabianq wants to merge 2 commits into
anilbeesetti:mainfrom
arabianq:fix/lampa-position

Conversation

@arabianq

Copy link
Copy Markdown

Fixes playback position sync when NextPlayer is launched as an external player from third-party apps like Lampa. Previously, when closing the video, the playback progress wasn't returned and the video started from the beginning next time.

What changed

  1. Always return playback result in finish()
    Due to singleTask launch mode, callingActivity is often null when launched from external apps. Previously, setResult() was wrapped in if (playerApi.shouldReturnResult) which relied on callingActivity != null, causing the player to finish silently without returning timecodes. Now setResult() is called unconditionally on finish.

  2. Improve Intent extra compatibility in PlayerApi

  • Added missing standard keys (extra_position, position_extra, extra_duration, start) to the companion object.
  • Removed the faulty second-to-millisecond conversion heuristic in the position getter that caused miscalculations for standard millisecond timestamps.
  • Return position both as Int (position) and Long (extra_position) in getResult() to avoid ClassCastException depending on how the calling app parses extras.
  1. Cache position in onStop()
    Saved lastKnownPosition and lastKnownDuration to ensure correct values are returned even if the media controller is released before finish() is called.

Testing

  • Tested playback progress saving and resume with Lampa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant