1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
5\page qtmultimedia-wasm.html
6\title Qt Multimedia on WebAssembly
7\brief Platform notes for WebAssembly
9This page covers the availability of Qt Multimedia features on WebAssembly.
13Due to the asynchronous nature of javascript, some features such as getting the list of
14QMediaDevices, will not be readily available and may take some time to request permissions and
15gather the list of devices.
17Playing video currently works by using an html 2d context, so all operations are on the CPU.
18This also means that only QGraphicsVideoItem/QGraphicsScene will work.
19There is no current support for QMultimediaWidgets / QVideoWidget which uses a webgl
20context to take processing onto the GPU.
22Performance is acceptable, although there is a copy on every frame, so it may be
23less performant than desktop platforms when playing hi-def video.
25Using and selecting different Codecs/video formats have not yet been tested, but whatever
26video formats the browser supports will most likely work.
28Playing streaming bytes instead of a url. e.g. setSource(QIOStream) is also not currently supported.
29Some advanced features may or may not work at this time.
31To setup playing a video file:
33 QMediaPlayer *player = new QMediaPlayer(this);
34 QAudioOutput audioOutput; // chooses the default audio routing
35 player->setAudioOutput(&audioOutput);
37 QGraphicsVideoItem *item = new QGraphicsVideoItem();
38 player->setVideoOutput(item);
40 QGraphicsScene *scene = new QGraphicsScene(this);
42 ui->graphicsView->setScene(scene);
43 ui->graphicsView->scene()->addItem(item);
44 ui->graphicsView->show();
46and then to play the url:
48 player->setSource(QUrl(urlStr));
51Files can be served from the/any web server. Because of the restriction on local file storage,
52playing local files is discouraged.