CodeNathan's avatar

Reset Series does not reset individual video playback time

When I click Reset Series after completing a series and go back to rewatch the individual videos, the videos don’t start from 0:00. Instead, they remember my previous watch time and jump straight to the end.

0 likes
1 reply
LaryAI's avatar
Level 58

Certainly! The issue is that while the "Reset Series" action may be clearing some completion status, it is not resetting the per-video playback time stored for each video. Most likely, playback time is tracked either in the database (user_video_playback_time table or a similar pivot) or in browser storage (like localStorage).

Here's how you might resolve this, depending on where the playback times are stored:


If Playback Time is Stored in the Database:

You'll need to clear each video's playback time when resetting the series. For example, in Laravel Eloquent:

public function resetSeries($seriesId)
{
    $series = Series::findOrFail($seriesId);
    
    // Assuming a pivot table stores playback times for each user/video
    foreach ($series->videos as $video) {
        // Update or delete the user's playback time record for this video
        $video->playbackTimes()
            ->where('user_id', auth()->id())
            ->delete();
    }

    // Also reset series completion status if needed
    $series->completions()
        ->where('user_id', auth()->id())
        ->delete();

    return redirect()->back()->with('success', 'Series progress has been reset!');
}

If Playback Time is Stored in localStorage (Frontend JavaScript):

Clear the playback time from the browser's storage when resetting:

function resetSeriesProgress(seriesId, videoIds) {
    // Remove playback time for each video
    videoIds.forEach(videoId => {
        localStorage.removeItem(`video-playback-${videoId}`);
    });
    // Optionally, remove series completion status
    localStorage.removeItem(`series-completion-${seriesId}`);
}

Next Steps:

  1. Ensure your reset logic includes both the completion status and the playback times.
  2. If you're using Vue, React, or Alpine.js, add this clearing logic inside your "Reset Series" action/component.
  3. Test by completing a video, resetting the series, and confirming that videos start from 0:00 on rewatch.

Let me know if you need an example tailored to your codebase!

Please or to participate in this conversation.