Skip to content

Fix _loop option does not loop the video #45

Description

@swashbuck

Subject of the issue

The _media._loop configuration option has no effect; videos do not loop when it is enabled.

Your environment

  • Framework 5.56.2
  • adapt-youtube v3.3.2
  • Chrome (latest), macOS

Steps to reproduce

  1. Add a YouTube component and set _media._loop to true.
  2. Play the video to the end.

Expected behaviour

The video restarts and plays again (loops).

Actual behaviour

The video stops at the end and does not loop.

There are two underlying causes:

  1. The template reads _loop at the root of the component config, but the option is defined at _media._loop in the schema, so the condition never matches.
  2. Even with the correct path, the YouTube IFrame API requires playlist=<videoId> alongside loop=1 to loop a single video, and because the component instantiates a YT.Player on the existing iframe, the API rewrites the iframe src and drops the playlist value. A blank playlist= also causes a "Video unavailable" error.

Suggested Fix

Handle looping through the player API instead of URL parameters: on the ENDED state, if _media._loop is enabled, call seekTo(0) and playVideo(). Remove the &loop= URL parameter, since URL-based looping suppresses the ENDED event the handler relies on.

Posted via collaboration with Claude Code

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status
Needs Reviewing

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions