Skip to content

Playback fails on modern mobile browsers due to outdated User-Agent sniffing #200

@oxypteros

Description

@oxypteros

Hello,
I've discovered a critical playback issue on modern mobile browsers (Chrome/Firefox on Android, ^v13).

The component fails to load and play the video when the needsYTApi path is triggered by the Mobi or Apple user-agent checks.

Setup Details

I am using the raw lite-yt-embed.js and .css files directly from the src directory, not a version installed via npm.
The version corresponds to the main branch as of commit 1b88628

Observed Behavior

  • On desktop browsers: works correctly.
  • On mobile browsers: the play button disappears, thumbnail remains, no controls appear, and the video never plays.

Diagnosis

A static <iframe> works correctly on mobile, indicating that the complex YT Player API workaround (triggered for mobile) is no longer necessary and is causing the playback failure.

Suggested Fix

Modify the detection logic to only use the complex API path when explicitly requested (js-api), and to use the simpler createBasicIframe() method for all other cases.

  • Change:
    this.needsYTApi = this.hasAttribute("js-api") || navigator.vendor.includes('Apple') || navigator.userAgent.includes('Mobi');
  • To:
    this.needsYTApi = this.hasAttribute("js-api");

I'm opening this issue to document the problem for others who may encounter it.
Thanks for the great library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions