Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress save doesn't work when video source changes #300

Open
AfaqAhmad0 opened this issue Dec 7, 2024 · 4 comments
Open

Progress save doesn't work when video source changes #300

AfaqAhmad0 opened this issue Dec 7, 2024 · 4 comments

Comments

@AfaqAhmad0
Copy link

I really love this extension but it lacks one thing resuming the video from where I left like if I was watching a movie and I stopped half way the next day I want to resume t from where I left It should automatically start from where I left.

**solution **
Solution is quite simple just save current time of the playing video by the name of the video or link as the identifier after some interval into local browser storage and when player starts check if there's any entry in local storage by this name.

Something I tried but I'm a beginner and don't know much
changed mediainfo in FastStreamClient

setMediaInfo(info) {
    this.mediaInfo = info;
    
    localStorage.setItem(`suggestedName`, info["name"]);
    
    this.interfaceController.subtitlesManager.mediaInfoSet();
  }

HandleResume

function handleVideoResume(video) {
  suggestedName = localStorage.getItem(`suggestedName`);    
  console.log(suggestedName," kkkkk")
  const storedTime = localStorage.getItem(suggestedName);

  // Resume playback if a stored time exists
  if (storedTime) {
      video.currentTime = parseFloat(storedTime);
      console.log(`Resuming video from ${storedTime} seconds`);
  }

  // Save playback position on pause or beforeunload
  video.addEventListener('pause', () => {
    console.log("Pause")
      localStorage.setItem(`video-time-${suggestedName}`, video.currentTime);
  });

  window.addEventListener('beforeunload', () => {
      localStorage.setItem(`video-time-${suggestedName}`, video.currentTime);
  });
}

it worked to some extent but not good enough some logical error maybe

@Andrews54757
Copy link
Owner

There is already an option to save your progress. It sets identifiers based on the source URL. if the source URL changes then the player won't recognize it.

@AfaqAhmad0
Copy link
Author

AfaqAhmad0 commented Dec 8, 2024

i looked for 'save progress' and it was there but the problem was URL was changing each time I play the video so what i did I replaced (in loadProgressData())

this.progressHashesCache = await this.progressMemory.getHashes(this.player.getSource().identifier);

with this:

const suggestedName = (this.mediaInfo?.name || 'video').replaceAll(' ', '_') ;
    this.progressHashesCache = await this.progressMemory.getHashes(suggestedName);

movies can rarely have exactly same names so there are very few chances of conflict even if they do it is not a big deal I'll just seek to start

another approach I tried is to use the url of tab as identifier although there can be multiple video on one tab but form me this is not the case

@Andrews54757
Copy link
Owner

when a name conflict occurs with auto-next enabled, the player might skip to the next video even though you haven't watched it yet. I will try to find another way.

@Andrews54757 Andrews54757 changed the title [Feature] Resume previously watching video Progress save doesn't work when video source changes Dec 10, 2024
@AfaqAhmad0
Copy link
Author

using the tab url is a better option i think or url+name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants