I am not able to save the state of each video respectively. Currently, when I press back from a playing video, I save the last time of that video and when I click on any other video it resumes to the last saved position. But I want each position to be saved independently.
What I am doing:
@Override
public void onBackPressed() {
super.onBackPressed();
videoView.pause();
mPlayVideoWhenForegrounded = videoView.getPlayer().getPlayWhenReady();
// Store off the last position our player was in before we paused it.
mLastPosition = videoView.getPlayer().getCurrentPosition();
// Pause the player
videoView.getPlayer().setPlayWhenReady(false);
//Here I am saving the last position in the database
sqLiteDatabaseHandler.add(new Contact(mLastPosition,""));
}
@Override
protected void onStart() {
super.onStart();
if (Build.VERSION.SDK_INT > 23) {
videoView.resume();
}
//getting db values
results = (ArrayList) sqLiteDatabaseHandler.getAll();
if(results.size()>0){
for (int i = 0; i < results.size(); i++) {
//value from databse of mLastPosition saved in onBackPressed()
seekto=results.get(i).getmLastPosition();
}
//seekto returns int value as 5604 or 7400
if(seekto>1000){
videoView.getPlayer().seekTo(seekto);
}
}
}
What is the issue I am facing:
With the above logic, I am able to pause and resume the video from where left off. But it resumes each video from the mLastPosition saved of any video. I want to save each video position differently. Please give me a logic on how can I store each video updated mLastPosition to resume it from the same. Basically, I want each should resume from a different time where it was paused.