Videoview Pausing and resuming

后端 未结 7 610
青春惊慌失措
青春惊慌失措 2020-12-08 06:19

I am new to android development and I am programming a game. My game has cutsceens that play before each level starts, cutsceens which are done through videoview. My problem

相关标签:
7条回答
  • Please try below code it will work absolutely fine

     @Override
    public void onPause() {
        super.onPause();
        stopPosition = videoView.getCurrentPosition(); //stopPosition is an int
        if (videoView.isPlaying())
            videoView.pause();
    }
    
    @Override
    public void onResume() {
        super.onResume();
        if (videoView != null) {
            videoView.seekTo(stopPosition);
        }
    }
    

    please make sure below line is mentioned in your Manifest.xml

    <activity
            android:name="<Video Play Activity Name Here>"
            android:configChanges="orientation|keyboardHidden|screenSize" 
            android:screenOrientation="landscape"
            ></activity>
    
    0 讨论(0)
提交回复
热议问题