The polyfill is not intended for use in production. It explores various discovery and launch mechanisms that the Presentation API could be built upon, with a view to providing concrete feedback on the specification to the Second Screen Working Group.
The polyfill explores discovery-based mechanisms (the controlling device discovers and controls the second device) and invitation-based mechanisms (the controlling device invites nearby devices to launch a URL). Presentation mechanisms that are currently supported are:
node Server/dial-proxy.js. The local backend server should work well across platforms.
node Server/ble-beacon.js. The local backend server has been tested successfully on Linux. It may not run on other platforms.
The establishment of a communication channel between the peers is either not fully implemented (Cast, Window) or simply not available at all when it cannot be established automatically (DIAL, HbbTV, QR Code). The polyfill uses an
isChannelOptional presentation request option flag to let the calling app specify whether it needs a communication channel (the default) or will handle the communication on its own. Advanced features such as reconnection to running presentations or even terminating a presentation is not supported either. The polyfill will be improved over time.
NB: The polyfill uses a
w3c prefix to avoid collisions with native implementations of the Presentation API.
Additional dependencies need to be included to enable some of the presentation mechanisms supported by the polyfill.
On the controlling side, the Presentation API polyfill must be included together with the Cast sender library to support the Cast presentation mechanism and the QRCode.js library for the QR code presentation mechanism. The application may then create a
w3cPresentationRequest instance and call
start() on that instance to effectively start the presentation and try to establish a communication channel with the receiving side.
Mechanisms that cannot be fully implemented within the Web runtime make use of a local Node.js backends to accomplish the tasks that they cannot achieve on their own. To launch these backends, first fetch the required code:
git clone https://github.com/mediascape/presentation-api-polyfill.git cd presentation-api-polyfill npm install
Then run each backend server in its own command-line window. To enable the Physical Web mechanism, run:
To enable the DIAL and HbbTV 2.0 mechanisms, run:
On the receiving side, the Presentation API polyfill must be included together with the Cast receiver library to support the Cast presentation mechanism, although note that the polyfill is useless when invitation-based mechanisms are used (such mechanisms do not know anything about the receiving so cannot connect with them). The receiving application may then monitor incoming presentation connections to be able to exchange messages with the controlling side.
The source code of the Presentation API polyfill is available on GitHub under a W3C Software and Document License.
The Presentation API JS polyfill closely follows the interfaces and algorithms defined in the latest draft of the Presentation API specification. On top of these interfaces, the Presentation API polyfill exposes a small set of interfaces that may be used to implement new presentation mechanisms. These classes are exposed in the
navigator.w3cPresentation.extend namespace. They are:
DOMException(pending support from browser vendors)
createDataChannel()method that the Presentation API polyfill running on the receiving side uses to establish the communication channel.
navigate()method it must implement.
getAvailableDisplays()method returns the promise to get a list of available displays. The
monitorIncomingControllers()method starts the monitoring of incoming controllers on the receiving side.
PresentationMechanisminstance to register themselves with the polyfill.
For feedback on the polyfill, use GitHub issues or get in touch with Francois Daoust if you do not wish your comment to appear in public.
Feedback on the Presentation API itself should be sent to the public mailing-list of the Second Screen Working Group.
This work was done with support from the European Commission under grant agreement no: 610404 (MediaScape).