How to continue video play while orientation change in android

后端 未结 2 1907
孤街浪徒
孤街浪徒 2021-01-21 01:33

I used videoview for playing a video in android default player. When I change its orientation, it starts playing from beginning.

How could I make it to continue from th

相关标签:
2条回答
  • 2021-01-21 02:00

    When you change the orientation the OS destroys your activity, and recreates it.

    You can save the actual progress of the video in onSaveInstanceState() and get the saved data in onRestoreInstanceState() from the Bundle, after that you can start the playing with either the progress data, or from the beginning if there was no data saved.

    0 讨论(0)
  • 2021-01-21 02:25

    Add:

    <activity
        android:name="...your_activity..."
        android:configChanges="screenSize|orientation|keyboardHidden"
    />
    

    to the AndroidManifest file, to the Activity that handles video play back.

    0 讨论(0)
提交回复
热议问题