- From: Takumi Fujimoto via GitHub <sysbot+gh@w3.org>
- Date: Thu, 05 Sep 2019 22:17:29 +0000
- To: public-secondscreen@w3.org
takumif has just created a new issue for https://github.com/w3c/presentation-api:
== One prompt for both PresentationRequest and RemotePlayback ==
**Problem:**
Presentation API and Remote Playback API each has a method to start a session, namely `PresentationRequest.start()` and `RemotePlayback.prompt()`.
Each shows a potentially different list of receiver devices to choose from, so the user may need to open two different device selection dialogs to find a device.
**Proposed solution:**
We show a single dialog showing devices capable of either presentation or remote playback. After the user chooses a device, the controlling page initiates a presentation or remote playback depending on its preference and the chosen device's capabilities.
Example code:
```javascript
const presentation = new PresentationRequest('https://example.com/myvideo.html');
const remote = document.querySelector('#my-video').remote;
const device = await navigator.secondScreen.prompt(presentation, remote);
// console.assert(device.supportsPresentation || device.supportsRemotePlayback);
if ((device.supportsPresentation && myPagePrefersPresentation()) ||
!device.supportsRemotePlayback) {
const connection = await device.startPresentation(); // Doesn't prompt
} else {
device.startRemotePlayback(); // Doesn't prompt
}
```
Web IDL:
```webidl
partial interface Navigator {
readonly attribute SecondScreen secondScreen;
};
interface SecondScreen {
Promise<SecondScreenDevice> prompt(PresentationRequest presentationRequest,
RemotePlayback remotePlayback);
};
interface SecondScreenDevice {
readonly attribute boolean supportsPresentation;
readonly attribute boolean supportsRemotePlayback;
Promise<PresentationConnection> startPresentation();
Promise<void> startRemotePlayback();
};
```
`SecondScreenDevice` must expire after some time, to prevent the controller page from holding onto it and starting a session later when the user is not expecting. `SecondScreenDevice` should become invalid at the same time as user gesture would become inactivated (UA dependent; in about one second on Chrome). Once invalid, `supportsPresentation` and `supportsRemotePlayback` become false.
A call to `startPresentation()` or `startRemotePlayback()` gets rejected if `supportsPresentation` or `supportsRemotePlayback` is false, respectively.
Please view or discuss this issue at https://github.com/w3c/presentation-api/issues/470 using your GitHub account
Received on Thursday, 5 September 2019 22:17:32 UTC