Open Miklesam opened 3 years ago
The problem with your approach is that the views are all being recreated (because you're not using configChanges = "orientation"
), but the player is not.
Hence you're effectively moving playback from one set of views to another. We don't support this for ad playbacks at the moment, unfortunately. It would be good for us to provide support, but this may also require changes in the IMA library, so I'm not sure how easy it would be. Marking this issue as an enhancement.
As of today, your options are to avoid recreating the views (like the demo app does with configChanges = "orientation"
) or to recreate the player (like the demo app does if you remove configChanges = "orientation"
with no other changes). Unfortunately the second option doesn't produce a particularly seamless transition, so I can see why it's not a very good solution.
@ojw28 Thanks for your reply.
Do I understand correctly that when the player is recreated, the ad request will be repeated and the ad will start playing from the beginning?
Is it possible not to re-request the ad again and save the place where the ad stopped?
Thanks for the help!
Hello, I am trying to find an example using a rather trivial case of screen rotation when playing an ad. But in the examples, the manifest contains:
android parameter: configChanges = "orientation", so when rotate, views does not recreating.
In my case, without android parameter: configChanges = "orientation". When I rotate the screen, I lose information about the advertisement.
https://user-images.githubusercontent.com/22328501/122461963-ad1b9780-cfbc-11eb-8162-a50ce3b51667.mp4
To solve the problem, I save playerView and add it to container when views recreate. But this method looks pretty crutch: (viewModel.playerView?.parent as ViewGroup).removeView(viewModel.playerView) findViewById(R.id.container).addView(viewModel.playerView)
Looks like that:
https://user-images.githubusercontent.com/22328501/122462060-c9b7cf80-cfbc-11eb-9393-863b05195ee0.mp4
Here's a repository with an example described https://github.com/Miklesam/IMA-SDK-Rotate
Please help me find the correct method when rotating the screen.
Thanks for all your help.