Skip to content

Conversation

@sarafarajnasardi
Copy link
Collaborator

lightbox: Open YouTube videos at correct timestamp.

Previously, opening a YouTube link with a timestamp (e.g., ?t=1m20s or ?start=80) in the lightbox would play the video from the beginning because the query parameters were ignored.

This commit updates the lightbox logic to correctly parse the t or start parameter from the URL and pass it to the embedded YouTube player so the video starts at the specific time intended by the sender.

Changes:

  • Added parse_youtube_start_time helper function in web/src/util.ts.
  • Updated web/src/lightbox.ts to use this helper and append the start parameter to the embed URL.
  • Added unit tests in web/tests/util.test.cjs to cover various timestamp formats.

Fixes: #36990

How changes were tested:

  1. Manual Verification:

    • Sent messages with YouTube links containing timestamps (e.g., t=42s, t=1m10s).
    • Clicked the video preview to open the lightbox.
    • Verified that the video started playing at the correct timestamp instead of 0:00.
  2. Automated Tests:

    • Added unit tests for parse_youtube_start_time covering formats like ?t=120, ?t=2m30s, and ?start=80.

Screenshots and screen captures:

Screencast.From.2025-12-10.23-07-38.online-video-cutter.com.mp4
Self-review checklist
  • Self-reviewed the changes for clarity and maintainability
    (variable names, code reuse, readability, etc.).

Communicate decisions, questions, and potential concerns.

  • Explains differences from previous plans (e.g., issue description).
  • Highlights technical choices and bugs encountered.
  • Calls out remaining decisions and concerns.
  • Automated tests verify logic where appropriate.

Individual commits are ready for review (see commit discipline).

  • Each commit is a coherent idea.
  • Commit message(s) explain reasoning and motivation for changes.

Completed manual review and testing of the following:

  • Visual appearance of the changes.
  • Responsiveness and internationalization.
  • Strings and tooltips.
  • End-to-end functionality of buttons, interactions and flows.
  • Corner cases, error conditions, and easily imagined bugs.

Previously, opening a YouTube link with a timestamp (e.g., `?t=42s`) in
the lightbox would play the video from the beginning because the query
parameters were ignored.

This commit extracts the `t` or `start` parameter from the URL using a
new helper `parse_youtube_start_time`, converts it to seconds, and
passes it to the YouTube embed URL as the `start` parameter.

Fixes zulip#36990
@sarafarajnasardi sarafarajnasardi force-pushed the youtube-videos-at-correct-time branch from 5feaf2e to 2ab073d Compare December 10, 2025 20:10
@zulipbot zulipbot added size: L and removed size: M labels Dec 10, 2025
@alya
Copy link
Contributor

alya commented Dec 10, 2025

Thanks! @karlstolley Are you the right person to review this one? I haven't tested.

@alya alya added the maintainer review PR is ready for review by Zulip maintainers. label Dec 10, 2025
@zulipbot
Copy link
Member

Heads up @sarafarajnasardi, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the upstream/main branch and resolve your pull request's merge conflicts accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open YouTube videos at correct timestamp in lightbox

4 participants