QtMultimedia in WebAssembly
Since Qt 6.5.0, QtMultimedia has support for playing video in a QGraphicsVideoItem and QGraphicsScene, as well as recording from a camera. You can use Qt to play video, access the camera from a web browser, thus simplifying deployment.
Browser permissions are required for accessing the microphone and camera, and a secure https context is a prerequisite for granting them. If this is not run or permission is not granted by the user, the list of available devices will be missing the label, or name, of any device not given permission and it will be unavailable for use.
Using the new QPermission API which will be introduced in Qt 6.5 will make sure your app is permissions ready. The example QtMultimedia apps have been changed in Qt 6.6 to use this API.
You do not need to use QPermissions in wasm, because it uses the same function - getUserMedia which causes the browser to ask for permissions.
The camera (and microphone) need user permissions. Something like this will work for granting permissions to use the camera:
When you connect to the signal QMediaDevices::videoInputChanged, it will be emitted when the list of camera devices are available.
You can try it out for yourself! camera-test
(Chrome 114 seems to have issue with VideoFrame, working with Chrome 117)
Permissions are not needed to play video.
Video currently only works with QWidget based apps. Playing video in quick apps will be fixed in an upcoming version of Qt. Here's a screenshot of the test app I used to develop it:
- List of media devices is not readily available for application.
- Video does not show in QtQuick declarative apps