Comments (10)
Actually I experimented with this several times before and I was able to fix the issue by changing the ordering. I'll follow up with a working sample that can demonstrate this.
from exoplayer-intro.
Thanks for filing this. Are you seeing unexpected behaviour in the codelab because of preparing the player after setting state?
The reason I ask is because the method signature for prepare
is
public void prepare(MediaSource mediaSource,
boolean resetPosition,
boolean resetState)
Both resetPosition
and resetState
are set to false
so any player state shouldn't be reset by the prepare
operation.
from exoplayer-intro.
Hello! It seems that after the device is rotated, the player's playback state cannot be properly restored if the player is prepared after the playback state values are set.
from exoplayer-intro.
I tested it on a Pixel 2 running Android 11 beta 2 and the playback position and state are preserved between orientation changes:
Is it the position, state or both which aren't preserved for you? Also, what device and Android build are you testing on?
from exoplayer-intro.
Hello!
I didn't realize that in the manifest file, android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|smallestScreenSize|uiMode" was set.
Well, if the app process was shut down due to resource constraints, then the player state wouldn't be properly restored (Nexus 5X, API 29):
Sometimes it wouldn't work even if I saved the values in onSaveInstanceState. Sometimes it would work, though. Not sure if this is a platform bug or ExoPlayer-specific issue.
from exoplayer-intro.
Thanks for the info.
Well, if the app process was shut down due to resource constraints, then the player state wouldn't be properly restored
Yes, that's true but I would assume that's because the fields (playWhenReady
etc) would be reinitialized after the Activity is recreated.
I still don't understand how the ordering of prepare
changes that behaviour though. Or are you saying it doesn't change the behaviour and that we have a separate issue with onSaveInstanceState
?
from exoplayer-intro.
Hello!
Here is the sample project.
There seems to be a platform bug of the passed in savedInstanceState bundle being null for the first process shutdown after app launch (which is another issue). Anyways, afterwards, the player's playback state just wouldn't be restored if the player was prepared after setting the state values, as shown in the video below:
And the issue can be resolved by changing the ordering, as shown in the video below:
from exoplayer-intro.
In your PlayerFragment
you have the line: player.prepare(mediaSource,true, true);
which will reset both playback position and state.
In the codelab this line is player.prepare(mediaSource, false, false);
Could that account for the behaviour you're seeing?
from exoplayer-intro.
Missed that! Thanks! Regarding that platform bug, where can I seek help?
from exoplayer-intro.
I'm pleased that you found the source of your problem. In future, please ensure that any issues are reproducible in the codelab rather than your own project.
For Android platform related issues you can file bugs here. I'd suggest using the "Framework" component for the issue you describe.
from exoplayer-intro.
Related Issues (20)
- Error when importing exoplayer-codelab-00 project into Android Studio HOT 1
- Override the default style: Use "exo_player_control_view" instead of "exo_playback_control_view" HOT 2
- Error: timestamp check failed at codelab stage 3
- Consider driving player initialization with androidx lifecycles
- Pull out library version strings common to modules
- Wrong download URL for project's zip file HOT 1
- Util.SDK_INT <= 23 or Util.SDK_INT <= 24
- Java style code into PlayerActivity.kt
- Wrong picture in step 7. Customize the user interface HOT 1
- Exoplayer Android SDK- Transferring media in .exo format to a peer phone application and allow the peer to play the content. HOT 1
- Assigning playWhenReady wrongly in codelab-00
- Codelab is using deprecated SimpleExoPlayer
- SimpleExoplayer is deprecated. Documentation should be updated
- Uses gradle v 6.8, causes issues on first compile HOT 1
- Can you add screenshots to the ReadMe page?
- Codelab seems really outdated and doesn't build out of the box. HOT 1
- Subtitle plays even after video completion
- Prueba general
- Codelab uses outdated element name for Step 3. Stream! Add the PlayerView element
- No funcion un streaming m3u8
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 exoplayer-intro.