VideoView in Android

后端 未结 2 2074
野趣味
野趣味 2020-12-18 12:03

I am using VideoView in Android for displaying streaming videos. While playing the videos if a user receives & disconnects the call ,the video starts playing from beginn

2条回答
  •  时光取名叫无心
    2020-12-18 12:28

    I have not tried this, but this is where I would start:

    Step #1: In onStop(), call getCurrentPosition() on the VideoView and save the value.

    Step #2: In onStart(), call getCurrentPosition() on the VideoView and compare it to the value from Step #1. If they differ (e.g., getCurrentPosition() is now 0), call seekTo(), supplying the value from Step #1.

    Step #3: In onSaveInstanceState(), call getCurrentPosition() on the VideoView and store the value in the supplied Bundle.

    Step #4: In onRestoreInstanceState(), obtain the value from Step #3 from the supplied Bundle and put it in the data member used by Step #1 and Step #2.

    This should cover you for the relevant scenarios that might occur while the phone call is going on.

提交回复
热议问题