google / google/ExoPlayer

Ads: Support moving playback from one view/activity to another

Open
#9,075 2 comments 0 reactions 1 assignee Assigned to @marcbaechinger View on GitHub
enhancement
Dominant language
Java
Stars
21.9k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.