Skip to content

Where is the video reference defined in the code? #669

@TrySpace

Description

@TrySpace

I must be crazy, but I can't figure out where the video is defined in: https://github.com/GoogleChrome/samples/blob/gh-pages/picture-in-picture/index.js

I'm assuming it's a document.getElementsByClassName("video"); ref, but I can't find where it is defined.
But I suspect it is something else, because I'm wondering why I'm getting a video.requestPictureInPicture is not a function when I try it on that ref, while when I right click the video, the PIP option is available and works...

const getVideoPIP = async () => {
  const video: any = document.getElementsByClassName("video-class");
  await video.requestPictureInPicture();
}

(So that class selector works, and is pointing to the same video as the one that works with right click PIP)

Update

Ok, it turns out, the class selector is not suitable, you need to use the getElementById selector...
Is this expected behaviour? I've never encountered this difference before...

Update 2
Ok, so the difference is that the class selector returns an array of elements, since they don't have to be unique.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions