Comments (1)
Thanks for the detailed problem description! As you already discovered, onEvents
is the best choice to see all 'atomic' state updates in a single method. This method also gives you access to the Player
to retrieve any current state values (in your example: the current media item, the playback state and playWhenReady
). You are right that this doesn't allow to access additional event parameters like the reason for a playWhenReady
change. If you need access to those, the best way is to overwrite the individual callback in addition to onEvents
and just save the last parameter so you can use it from onEvents
. As long as you check that the event happened, you are guaranteed that the value has been updated with the latest value and can be safely used. Please also see the last sentence in this guide that tries to highlight the same approach: https://developer.android.com/media/media3/exoplayer/listening-to-player-events#individual-callbacks
int playWhenReadyChangeReason;
public void onPlayWhenReadyChanged(boolean playWhenReady, int reason) {
playWhenReadyChangeReason = reason;
}
public void onEvents(Player player, Events events) {
if (events.contains(Player.EVENT_PLAY_WHEN_READY_CHANGED)
&& playWhenReadyChangeReason == Player.PLAY_WHEN_READY_CHANGE_REASON_USER_REQUEST
&& player.getCurrentMediaItem() != null
&& (player.getPlaybackState() == Player.STATE_BUFFERING
|| player.getPlaybackState() == Player.STATE_READY)) {
// ...
}
}
from media.
Related Issues (20)
- Support working bandwidth estimator in blocking media segment of LL-HLS
- How do I detect if media item transition has been triggered from next or previous seek? HOT 2
- IMA DAI SDK indicates AD_BREAK_ENDED before ad playback completes HOT 4
- Black screen displayed for DRM content HOT 4
- Allow changing SNTP client timeout HOT 2
- Player gets stuck in the "loading" state after seekToNext/Prev MediaItem HOT 8
- PlayerControlView will show as minimal mode when height is set to wrap_content HOT 2
- How to play downloaded content with a player in a MediaSession(Service)? HOT 2
- Is there support of sleep timer? HOT 2
- player.addMediaItems or player.setMediaItems takes too much time HOT 3
- "onSurfaceTextureSizeChanged" will not called with new size when use Video Effects. HOT 3
- NetworkTypeObserver makes binding calls on mainthread by default HOT 2
- Getting the decoded from ExoPlayer in advance HOT 9
- Playing a song using MediaSessionService randomly turns on and off bluetooth for some reason on Android 11. HOT 9
- Render subtitles (Cue objects) via an Effect HOT 8
- Current application thread check for player.createMessage HOT 4
- Creating a perpetually loading MediaItem HOT 4
- HttpMediaDrmCallback setKeyRequestProperty PSSH name for header request HOT 1
- Media resumption results in DeadObjectException HOT 2
- Libflac decoder crash: flac_jni.cc (NewStringUTF)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from media.