w3c / picture-in-picture

Picture-in-Picture (PiP)
https://w3c.github.io/picture-in-picture
Other
311 stars 39 forks source link

Metadata for the video element are not loaded yet #91

Closed vasylnakvasiuk closed 5 years ago

vasylnakvasiuk commented 5 years ago

Chrome 70, macOS 10.13.6

This example doesn't work for me:

<canvas id="canvas"></canvas>

<button id="pipButton"></button>

<script>
  pipButton.addEventListener('click', function() {
    const video = document.createElement('video');
    video.autoplay = true;
    video.srcObject = canvas.captureStream(60 /* fps */);
    video.requestPictureInPicture();
  });
</script>

I got an error: Uncaught (in promise) DOMException: Metadata for the video element are not loaded yet.

P.S. If I try the same (video.requestPictureInPicture()) here: https://webrtc.github.io/samples/src/content/capture/canvas-video/ I got an error: Uncaught (in promise) DOMException: Media Streams are not supported yet.

So, where is truth?

vasylnakvasiuk commented 5 years ago

@beaufortfrancois @mounirlamouri could you help, please?

beaufortfrancois commented 5 years ago

Both are truth ;)

In the first one, you simply have to wait for the loadedmetadata event to be fired before requesting Picture-in-Picture. Or you can simply make sure there's something drawn in the canvas. See https://github.com/WICG/picture-in-picture/pull/94/files

In the second one, it is not stable yet but you can enable the experimental chrome://flags/#enable-surfaces-for-videos-ms flag in Chrome Canary to play with MediaStreams.

vasylnakvasiuk commented 5 years ago

@beaufortfrancois thanks a lot. Awesome feature! In "Chrome Canary" this flag really works (however this flag exists in stable Chrome 70, but has no affect).

It's cool feature and open many opportunities for modern web. I wonder, when Google Chrome team plan to launch this for stable version? Any estimates?

mounirlamouri commented 5 years ago

@vaxXxa we usually don't provide estimates but as you said yourself, the feature is working on Canary so it shouldn't be long until it's enabled in Stable.

beaufortfrancois commented 5 years ago

@mounirlamouri message seems to be missing.

@vaxXxa we usually don't provide estimates but as you said yourself, the feature is working on Canary so it shouldn't be long until it's enabled in Stable.

beaufortfrancois commented 5 years ago

@mounirlamouri message seems to be missing.

@vaxXxa we usually don't provide estimates but as you said yourself, the feature is working on Canary so it shouldn't be long until it's enabled in Stable.

beaufortfrancois commented 5 years ago

@mounirlamouri's message seems to be missing:

@vaxXxa we usually don't provide estimates but as you said yourself, the feature is working on Canary so it shouldn't be long until it's enabled in Stable.