New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 877546 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Aug 27
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Android , Windows , Chrome , Mac
Pri: 2
Type: Bug



Sign in to add a comment

Presentation API: Receiver pages won't play videos, complain about lack of interaction

Project Member Reported by sdy@chromium.org, Aug 24

Issue description

Chrome Version: Sender: 70.0.3530.0, receiver: [Whatever Chromecast Ultra runs currently — I'm not near the device unfortunately.]
OS: macOS 10.13.6 (17G65) / [See above]

What steps will reproduce the problem?
(1) Create a minimal receiver web page that plays a video, e.g.:

    <!DOCTYPE html>
    <video autoplay src="http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_stereo_abl.mp4"></vide>

*or* a more involved one that receives messages (note: I made some tweaks to this one w/o being able to test it, so beware):

  <!DOCTYPE html>
  <video id=video>
    <source src="http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_stereo_abl.mp4" type="video/mp4">
  </video>
  <script>
  "use strict";
  const video = document.getElementById("video");

  navigator.presentation.receiver.connectionList.then(function (list) {
    const handleConnection = connection => {
      connection.onmessage = e => {
        const message = JSON.parse(e.data);
        switch (message.action) {
          case "play":
            video.play()
              .then(m => connection.send(m))
              .catch(e => connection.send(e))
            ;
            break;
        }
      };
    };

    list.connections.map(handleConnection);
    list.addEventListener('connectionavailable', handleConnection);
  });

  </script>

…plus, make a sender page:

    <!DOCTYPE html>
    <button id=cast>Go</button>
    <button id=play>Play</button>
    <script>

    let currentConnection;

    document.getElementById('cast').addEventListener('click', e => {
      if (currentConnection) {
        currentConnection.terminate();
        currentConnection = null;
      }
      (new PresentationRequest('receiver.html'))
        .start()
        .then(conn => {
          conn.addEventListener('message', console.log.bind(console));
          currentConnection = conn;
        });
    });

    document.getElementById('play').addEventListener('click', e => {
      if (!currentConnection)
        return;
      currentConnection.send(JSON.stringify({ action: 'play' }));
    });

    </script>

(2) Host both pages on a web server that's accessible to a Chromecast, click "Go" on the sender page, and start casting.
(3) Click "Play" on the sender page.

What is the expected result?
In the simple case, the video starts playing right away (probably). In the message-based case, the video starts playing when I click "Play".

What happens instead?
This is logged in the console on the sender page:

> NotAllowedError: play() failed because the user didn't interact with the document first. https://goo.gl/xX8pDD
 
Cc: johnpallett@chromium.org
Components: -Chromecast
Components: Blink>Media>Autoplay
Labels: OS-Android OS-Chrome OS-Linux OS-Mac OS-Windows
Owner: mlamouri@chromium.org
Status: Started (was: Untriaged)
Project Member

Comment 3 by bugdroid1@chromium.org, Aug 27

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8627f57b9bdafccc6f79e37a999c10b67a42fddb

commit 8627f57b9bdafccc6f79e37a999c10b67a42fddb
Author: Mounir Lamouri <mlamouri@chromium.org>
Date: Mon Aug 27 22:24:46 2018

Autoplay: allow autoplay for Presentation Receiver document.

The autoplay policy shouldn't apply to a Presentation Receiver document
given that it has to be created via the Presentation API and is only
visible on the second screen.

Bug:  877546 
Change-Id: I346883ba68247889506f0abb84bccfbe6c82fdb9
Reviewed-on: https://chromium-review.googlesource.com/1191529
Reviewed-by: mark a. foltz <mfoltz@chromium.org>
Reviewed-by: Becca Hughes <beccahughes@chromium.org>
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586448}
[add] https://crrev.com/8627f57b9bdafccc6f79e37a999c10b67a42fddb/third_party/WebKit/LayoutTests/virtual/presentation/receiver/presentation-receiver-autoplay.html
[modify] https://crrev.com/8627f57b9bdafccc6f79e37a999c10b67a42fddb/third_party/blink/renderer/core/html/media/autoplay_policy.cc

Status: Fixed (was: Started)
sdy@, thank you for catching this issue and filing the bug report! :)

Sign in to add a comment