Exoplayer: PlayerNotificationManager behavior during ads.

Created on 19 Jul 2018  路  5Comments  路  Source: google/ExoPlayer

What is the desired behavior of PlayerNotificationManager while advertisements are playing?

What I have mostly observed is that the notification doesn't display while ads are playing and then starts displaying once the main content begins.

However I have observed a crash while playing an ad on a Pixel C running Android 8.1.0.
I've observed this behavior with and without a media session token.

android.app.RemoteServiceException: Bad notification posted from package <MY-PACKAGE>: 
Couldn't inflate contentViewsjava.lang.IllegalArgumentException: 
setShowActionsInCompactView: action 0 out of bounds (max -1)

I think this is because getActions() returns an empty array if the player is playing ads and getActionIndicesForCompactView(player) doesn't check if the player is playing ads which leads to it returning an index that doesn't exist.

My gut feeling here is that the notification is being swallowed by this error on most devices which looks like desirable behavior, but the exception crashes hard on a Pixel C.

I'd be happy to open a PR to fix if I knew what the intention was for the PlayerNotificationManager while advertisements play.

bug

All 5 comments

@marcbaechinger - Could you take a look?

The preferred behaviour is that the notification is shown during ads, but playback control actions are not shown.

The crash you've seen is a abug and the fix is what you describe. We'll fix that. Thanks for reporting.

Thanks! 馃帀

I'm still getting this crash on r2.8.3.
From a Nexus 5x when playing ads:

android.app.RemoteServiceException: Bad notification posted from package <MY_PACKAGE_NAME>: Couldn't inflate contentViewsjava.lang.IllegalArgumentException: setShowActionsInCompactView: action 0 out of bounds (max -1)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

The fix wasn't included in 2.8.3. It'll be part of 2.9.0.

Was this page helpful?
0 / 5 - 0 ratings