Handling Orientation Change with the Native SDK for Android

Product(s)
Brightcove Player
Video Cloud
Role(s)
Device SDK Developer
Task(s)
Create & Configure Players
Topic(s)
Styling
SDK
Android

In this topic, you will learn how to prevent the BrightcoveVideoView from restarting the currently playing video on an orientation change. By adding code to the AndroidManifest.xml you can prevent this unwanted default behavior.

 

Default behavior

By default when an orientation change occurs the current Activity is destroyed and recreated. When retrieving and playing a Brightcove video, this causes the catalog request to be performed again and the BrightcoveVideoView is recreated. This takes both time and bandwidth.

Best practice

It's more efficient to handle the orientation change as a device configuration change. This keeps the Activity instantiated, and just the layout is invalidated. To do this, you can modify the AndroidManifest.xml.

To make a device rotation a configuration change add the following code to the <activity> tag in the AndroidManifest.xml.

android:configChanges="orientation|screenSize"