16#include "../QtPlayer.h"
26#include <QApplication>
30 , vbox(new QVBoxLayout(this))
31 , menu(new QMenuBar(this))
33 , player(new
openshot::QtPlayer(video->GetRenderer()))
35 setWindowTitle(
"OpenShot Player");
37 menu->setNativeMenuBar(
false);
39 QAction *action = NULL;
40 action = menu->addAction(
"Choose File");
41 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(open(
bool)));
43 vbox->addWidget(menu, 0);
44 vbox->addWidget(video, 1);
51 setFocusPolicy(Qt::StrongFocus);
62 QWidget *pWin = QApplication::activeWindow();
70 if (event->key() == Qt::Key_Space || event->key() == Qt::Key_K) {
81 if (player->
Speed() == 0)
91 else if (event->key() == Qt::Key_J) {
92 if (player->
Speed() - 1 != 0)
100 else if (event->key() == Qt::Key_L) {
101 if (player->
Speed() + 1 != 0)
110 else if (event->key() == Qt::Key_Left) {
111 if (player->
Speed() != 0)
115 else if (event->key() == Qt::Key_Right) {
116 if (player->
Speed() != 0)
120 else if (event->key() == Qt::Key_Escape) {
121 QWidget *pWin = QApplication::activeWindow();
126 QApplication::quit();
130 QWidget::keyPressEvent(event);
133void PlayerDemo::open(
bool checked)
136 const QString filename = QFileDialog::getOpenFileName(
this,
"Open Video File");
137 if (filename.isEmpty())
return;
140 QString project_json =
"";
141 if (filename.endsWith(
".osp")) {
142 QFile file(filename);
143 if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
145 while (!file.atEnd()) {
146 QByteArray line = file.readLine();
147 project_json += line;
154 player->
SetSource(filename.toStdString());
Header file for demo application for QtPlayer class.
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
PlayerDemo(QWidget *parent=0)
void Seek(int64_t new_frame)
Seek to a specific frame in the player.
void SetSource(const std::string &source)
Set the source URL/path of this player (which will create an internal Reader)
void Reader(openshot::ReaderBase *new_reader)
Set the current reader.
int64_t Position()
Get the current frame number being played.
float Speed()
Get the Playback speed.
void Play()
Play the video.
openshot::PlaybackMode Mode()
Get the current mode.
void Pause()
Pause the video.
void SetTimelineSource(const std::string &json)
Set the source JSON of an openshot::Timelime.
void Stop()
Stop the video player and clear the cached frames.
This namespace is the default namespace for all code in the openshot library.
@ PLAYBACK_PAUSED
Pause the video (holding the last displayed frame)
@ PLAYBACK_PLAY
Play the video normally.