androidx / androidx/media

Media3 play next / play previous

Open
#1,449 1 comment 0 reactions 1 assignee View on GitHub

@marcbaechinger is already working on this.

Since Jun 14, 2024.

bug
Dominant language
Java
Stars
3k
Forks
955
Avg merge
12d 14h
Merged PRs (30d)
2

Description

Version

Media3 1.3.1

More version details

No response

Devices that reproduce the issue

Pixel 8 Pro,
Samsung S21,
Xiaomi Redmi note 11 pro

pixel1 SmartWatch

huawei FreeBuds 2,
Crusher ANC 2

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

In my app i use media3 in MediaSessionService where i start my ExoPlayer instance.

I use :

  • ForwardingPlayer to set/add commands.
  • MediaSession.Callback to override onMediaButtonEvent() and intercept KEYCODE_MEDIA_NEXT / KEYCODE_MEDIA_PREVIOUS ( we use custom streams with DRM license and i need to intercept to set by code the next stream)

Scenario 1 :
a) In my main test i use : Pixel 8 Pro + Pixel 1 smartWatch + Huawei FreeBuds2
b) on the next 2 examples i set only 1 media item on startup

Example 1 :
if i remove COMMAND_SEEK_TO_NEXT and COMMAND_SEEK_TO_PREVIOUS ( by using ForwardingPlayer ) :

  • no play next/prev buttons on media3 notification on my phone
  • play next/prev buttons on my smartwatch are disable
  • but if i use next/prev from my huawei freeBuds2 -> i can intercept action in onMediaButtonEvent()
    ==> i was hopping not to get event play netx/prev on onMediaButtonEvent() ( but not this is my problem)

Example 2 :
If i add COMMAND_SEEK_TO_NEXT and COMMAND_SEEK_TO_PREVIOUS :

  • i get play next/prev buttons on media3 notification on my phone but when i press them it seems to reload my stream and i don't get any event triggered in onMediaButtonEvent()
  • play next/prev buttons on my smartwatch are enabled and i get expected event on onMediaButtonEvent()
  • play next/prev actions from my huawei freeBuds2 works like above and now as expected

The problem => i was hopping after i add those 2 media commands that works fine on my pixel smartWatch, to work the same from my media3 notification on my phone

Scenario 2 :
a) In my main test i use : Pixel 8 Pro + Pixel 1 smartWatch + Huawei FreeBuds2
b) on the next example i set 3 media items ; First one as test hardcpded stream (to have and simulate "prev" action ), second one is the real stream that start playing and third one as fake media item to simulate "next" (startIndex 1 , startPositionMs 0 )

Example 1 :
if i add COMMAND_SEEK_TO_NEXT and COMMAND_SEEK_TO_PREVIOUS ( by using ForwardingPlayer ) :
-> now i can play next/prev from any above devices but i don't get any prev/next event on onMediaButtonEvent() ( to be able to intercept and prepare the next/prev stream ). It plays (next/prev) from the mediaItem lists where i hardcoded 2 streams

Obs:
When i receive events on onMediaButtonEvent i get those triggered by play/next action from divices as : KeyEvent.KEYCODE_MEDIA_NEXT or KeyEvent.KEYCODE_MEDIA_PREVIOUS

What commands to set to be able to intercept them as play next/previous actions sended from any of my devices ( phone - media3 notification, smartWatch or headphones in my onMediaButtonEvent() overide function from MediaSession.Callback implementation ?

Or

Is there any other solution to play a stream, still have prev/next action , intercept those action to prepeare the next/prev stream

Thanks

Expected result

By using ForwardingPlayer and added COMMAND_SEEK_TO_NEXT and COMMAND_SEEK_TO_PREVIOUS i was hopping to intercept play next/prev from any of my devices ( phone, headphones or smartwatch) the same in any

Actual result

By using ForwardingPlayer and added COMMAND_SEEK_TO_NEXT and COMMAND_SEEK_TO_PREVIOUS i can intercept play next/prev only from headphones or smartwatch and kind of stream reload ( i think ) from media 3 notification

Media

any media

Bug Report
  • You will email the zip file produced by adb bugreport to android-media-github@google.com after filing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.