text-not-call's avatar

A few bugs related to auto switch to the next lesson

Hi guys, I've stumbled upon a few bugs when a lesson ends and tries to automatically switch to the next lesson. I have not found a form to submit bugs, so I'm trying to post here. Please point me in the right direction if there's a special place for it

  1. When a lesson finishes in fullscreen video mode, instead of switching it displays an error: "Invalid playback URL. The video URL or playback-token are formatted with incorrect or incomplete information". Exiting fullscreen mode switches to the next video right away. This issue appeared in some other cases a few times too but I cannot remember the exact steps to reproduce at the moment
  2. If you finish a lesson you've already finished before then auto switch marks as "not complete". I'm not sure it is the intended behavior šŸ˜…

Just in case, I'm using Google Chrome 147.0.7727.56 on macOS

1 like
3 replies
LaryAI's avatar
Level 58

Certainly! Here’s a well-structured answer you could give on Laracasts to address both bugs, and provide some guidance:


Thanks for reporting these issues! I’ll address both points and provide some troubleshooting steps and recommendations.

1. Fullscreen Mode Causes Video Playback Error

Diagnosis:
This error commonly arises in custom video players when the video DOM node is replaced or upgraded while in fullscreen, or when the player attempts to load a new video source without properly exiting fullscreen first. Many browsers restrict DOM manipulations while in fullscreen for security and stability reasons.

Suggestion:
When switching to the next lesson/video, explicitly exit fullscreen mode via the video player's API before updating the video source.

Example fix using vanilla JS:

function exitFullscreenIfActive() {
    if (document.fullscreenElement) {
        document.exitFullscreen();
    }
}

function autoSwitchToNextLesson(nextVideoUrl) {
    exitFullscreenIfActive();
    // Now safely set the new video URL/source here
    // e.g., videoPlayer.src = nextVideoUrl;
}

If you're using a frontend framework or a video player library (like Video.js), the approach will be similar—always exit fullscreen before switching sources. This should prevent the ā€œInvalid playback URLā€ error.


2. Auto Switch Marks Lesson as "Not Complete"

Diagnosis:
Sounds like the client-side state or backend marking logic resets the completed state when revisiting and auto-switching lessons, possibly due to optimistic updates or API mis-handling.

Suggestion:
Ensure your ā€œmark as completeā€ logic properly checks for existing completion status and does not inadvertently unset it. When auto-switching, make sure to only send API requests to mark as complete and never to mark as incomplete, unless the user intentionally requests that.

Example (pseudo-code):

function handleLessonEnd(currentLessonId) {
    if (!hasBeenMarkedComplete(currentLessonId)) {
        markLessonAsComplete(currentLessonId);
    }
    autoSwitchToNextLesson();
}

If you’re using Vue/React, make sure your state reflects the API’s true status and doesn't overwrite the completed status on auto-navigation.


Where to Report Bugs

There isn’t an official bug submission form for Laracasts, but posting here is the right move! Staff and community members monitor this forum. If you want direct support, you can use the Contact form (found at the footer of the site) for persistent issues.


TL;DR

  • Explicitly exit fullscreen mode before switching video sources to avoid playback URL errors.
  • Confirm auto-switch logic does not unset an already completed lesson when revisiting or auto-switching.
  • Use the Laracasts Contact form for additional support if needed.

Let me know if you’d like more specific code samples based on your front-end stack or video player library!

imranbru's avatar

It sounds like the auto-switch lifecycle is hitting a generic toggle() endpoint instead of explicitly enforcing a complete state. Re-watching an already finished video is just flipping the boolean back to false.

cupok's avatar

Can confirm the issue!

On-screen error: "Invalid playback URL — The video URL or playback-token are formatted with incorrect or incomplete information."

Network response (403): {"error":{"messages":["Not Authorized"],"type":"not_authorized"}}

Environment:

  • Browser: Google Chrome 147.0.7727.102 (arm64)
  • OS: macOS Tahoe 26.4.1 (25E253)

https://www.chromium.org/Home/chromium-security/corb-for-developers/


Update: dug into this further with Claude. CORB/ORB ruled out — relaunched Chrome with --disable-features=CrossSiteDocumentBlockingAlways,CrossSiteDocumentBlockingIfIsolating and the 403s persisted unchanged. The manifest 403s are coming from Mux's edge, not from Chrome.

The actual cause looks like a token/URL desync in the fullscreen next-episode flow. Decoded the JWTs from a working vs. failing .m3u8 request:

  • Working — URL playback_id: u6VKm…, token sub: u6VKm… āœ… match
  • Failing — URL playback_id: u6VKm…, token sub: NuS3Y2YC… āŒ mismatch

Both tokens have aud: "v" and valid exp (the failing one is actually 72 seconds fresher than the working one, so not an expiry issue). The token is just bound to a different playback_id than the manifest URL is requesting — almost certainly the next episode's id.

My read: in default mode, "next episode" does a full page navigation, so URL and token get rewritten together. In fullscreen mode, the player swaps source in-place and the two updates desync — a fresh token gets minted for the upcoming episode, but the manifest URL still points at the current one. Mux correctly returns 403 because token.sub doesn't match the requested resource.

Happy to share the cURL captures of both requests if useful.

Please or to participate in this conversation.