Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
video.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4// Video related snippets
5// Extracted from src/multimedia/doc/snippets/multimedia-snippets/video.cpp
6#include "qmediaplayer.h"
7#include "qvideowidgetcontrol.h"
8#include "qvideowindowcontrol.h"
10#include "qmediaplaylist.h"
11
12#include <QFormLayout>
13#include <QGraphicsView>
14
15class VideoExample : public QObject {
17public:
20
21private:
22 // Common naming
23 QMediaPlaylist *playlist;
24 QVideoWidget *videoWidget;
25 QFormLayout *layout;
26 QMediaPlayer *player;
27 QGraphicsView *graphicsView;
28};
29
31{
33 player = new QMediaPlayer;
34
35 playlist = new QMediaPlaylist(player);
36 playlist->addMedia(QUrl("http://example.com/myclip1.mp4"));
37 playlist->addMedia(QUrl("http://example.com/myclip2.mp4"));
38
39 videoWidget = new QVideoWidget;
40 player->setVideoOutput(videoWidget);
41
42 videoWidget->show();
43 playlist->setCurrentIndex(1);
44 player->play();
46
47 player->stop();
48}
49
51{
53 player = new QMediaPlayer(this);
54
56 player->setVideoOutput(item);
57 graphicsView->scene()->addItem(item);
58 graphicsView->show();
59
60 player->setMedia(QUrl("http://example.com/myclip4.ogv"));
61 player->play();
63}
The QFormLayout class manages forms of input widgets and their associated labels.
Definition qformlayout.h:18
void addItem(QGraphicsItem *item)
Adds or moves the item and all its children to this scene.
The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaPlayer ...
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
QGraphicsScene * scene() const
Returns a pointer to the scene that is currently visualized in the view.
The QMediaPlayer class allows the playing of a media files.
void setVideoOutput(QObject *)
void stop()
\qmlmethod QtMultimedia::MediaPlayer::stop()
void play()
\qmlmethod QtMultimedia::MediaPlayer::play()
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
Definition qurl.h:94
The QVideoWidget class provides a widget which presents video produced by a media object.
void show()
Shows the widget and its child widgets.
Definition qwidget.cpp:7875
[Video producer]
Definition video.cpp:45
void VideoGraphicsItem()
void VideoWidget()
#define Q_OBJECT
QGraphicsItem * item