Android YouTube API video pause when rotate screen or hide player

What did the trick for me is to add:

android:configChanges="keyboardHidden|orientation|screenSize"

to your android manifest.

Cheers..


<activity 
android:label="YoursActivityName" 
android:configChanges="keyboardHidden|orientation|screenSize"
android:name="com.example.naren.YoursActivityName" /> 

Add it in yours manifest file.


When you flip the screen, the activity that was playing the video gets destroyed, and a new activity gets created with everything reset. Its a feature, not a bug. :)

There are a handful of ways of dealing with this; you will probably have to save off some state and then check for any saved data when any new activity gets created, manage the data, etc. Check out: Keeping data view/layout in Android after screen rotate/activity destroyed.