0

At the begging I know to save/restore variables in the rotate process. I need to store the state of SimpleExoPlayer whether play or paused

ExoPlayer doesn’t restore its state on rotation (even if it is on paused the video always starts playing on configuration change) because I used this line of code

mExoPlayer.setPlayWhenReady(true);

so in case of user clicked in pause and rotate the screen it still start

when I googled for this issue I found that I must use a boolean variable instead of true

mExoPlayer.setPlayWhenReady(playWhenReady);

but I found the mExoplaer variable with a null

the screen for debugging here

the screen of code in on saveInstance here

the screen of retrieve of boolean variable here

the screen of mExoPlayer init here then invoke this method in inCreateView

can anyone help me?

Moustafa EL-Saghier
  • 1,721
  • 1
  • 13
  • 43
  • Also, your debugger says that exoplayer is null at the break. Are you getting a NullPointerException? If not, then post the Exception data as well in addition to the onSaveInstanceState method override. If you are getting NullPointerException, fix your exoplayer being null before adding data to the outState Bundle. – ReverseEffect Dec 26 '17 at 00:43
  • you probably don't save your instance variables, take a look at this question among others : https://stackoverflow.com/questions/32121761/android-save-variables-and-settings-on-rotation – Climbatize Dec 26 '17 at 00:46
  • Possible duplicate of [Android: Save variables and settings on rotation](https://stackoverflow.com/questions/32121761/android-save-variables-and-settings-on-rotation) – Climbatize Dec 26 '17 at 00:47
  • check the second image, – Moustafa EL-Saghier Dec 26 '17 at 00:50
  • yes i get NullPointerException so that i ask for help as in side method the player value equal to null outside of method it allocated to memory location – Moustafa EL-Saghier Dec 26 '17 at 00:55
  • How are you maintaining the mExoPlayer variable? Are you setting it to null before rotation (or anywhere else in your code?) – ReverseEffect Dec 26 '17 at 00:59
  • @ReverseEffect not .. i just init it will edit post with pic for that – Moustafa EL-Saghier Dec 26 '17 at 01:01
  • @ReverseEffect edited – Moustafa EL-Saghier Dec 26 '17 at 01:04

0 Answers0