Giter Site home page Giter Site logo

Comments (10)

rabyunghwa avatar rabyunghwa commented on June 11, 2024 1

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 codelab-exoplayer-intro.

dturner avatar dturner commented on June 11, 2024

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 codelab-exoplayer-intro.

rabyunghwa avatar rabyunghwa commented on June 11, 2024

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 codelab-exoplayer-intro.

dturner avatar dturner commented on June 11, 2024

I tested it on a Pixel 2 running Android 11 beta 2 and the playback position and state are preserved between orientation changes:
exoplayer-intro-issue49

Is it the position, state or both which aren't preserved for you? Also, what device and Android build are you testing on?

from codelab-exoplayer-intro.

rabyunghwa avatar rabyunghwa commented on June 11, 2024

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):

20200714_183739

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 codelab-exoplayer-intro.

dturner avatar dturner commented on June 11, 2024

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 codelab-exoplayer-intro.

rabyunghwa avatar rabyunghwa commented on June 11, 2024

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:

20200714_223442

And the issue can be resolved by changing the ordering, as shown in the video below:

20200714_223348

from codelab-exoplayer-intro.

dturner avatar dturner commented on June 11, 2024

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 codelab-exoplayer-intro.

rabyunghwa avatar rabyunghwa commented on June 11, 2024

Missed that! Thanks! Regarding that platform bug, where can I seek help?

from codelab-exoplayer-intro.

dturner avatar dturner commented on June 11, 2024

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 codelab-exoplayer-intro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.