34 #include "../QtPlayer.h" 36 #include <QMessageBox> 37 #include <QFileDialog> 43 #include <QCloseEvent> 44 #include <QApplication> 48 , vbox(new QVBoxLayout(this))
49 , menu(new QMenuBar(this))
51 , player(new
openshot::QtPlayer(video->GetRenderer()))
53 setWindowTitle(
"OpenShot Player");
55 menu->setNativeMenuBar(
false);
57 QAction *action = NULL;
58 action = menu->addAction(
"Choose File");
59 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(open(
bool)));
61 vbox->addWidget(menu, 0);
62 vbox->addWidget(video, 1);
69 setFocusPolicy(Qt::StrongFocus);
80 QWidget *pWin = QApplication::activeWindow();
88 if (event->key() == Qt::Key_Space ||
event->key() == Qt::Key_K) {
99 if (player->
Speed() == 0)
109 else if (event->key() == Qt::Key_J) {
110 if (player->
Speed() - 1 != 0)
118 else if (event->key() == Qt::Key_L) {
119 if (player->
Speed() + 1 != 0)
128 else if (event->key() == Qt::Key_Left) {
129 if (player->
Speed() != 0)
133 else if (event->key() == Qt::Key_Right) {
134 if (player->
Speed() != 0)
138 else if (event->key() == Qt::Key_Escape) {
139 QWidget *pWin = QApplication::activeWindow();
144 QApplication::quit();
148 QWidget::keyPressEvent(event);
151 void PlayerDemo::open(
bool checked)
154 const QString filename = QFileDialog::getOpenFileName(
this,
"Open Video File");
155 if (filename.isEmpty())
return;
158 player->
SetSource(filename.toStdString());
float Speed()
Get the Playback speed.
PlayerDemo(QWidget *parent=0)
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
void Pause()
Pause the video.
void SetSource(const std::string &source)
Set the source URL/path of this player (which will create an internal Reader)
Pause the video (holding the last displayed frame)
void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE
Header file for demo application for QtPlayer class.
int64_t Position()
Get the current frame number being played.
void Reader(openshot::ReaderBase *new_reader)
Set the current reader.
void Play()
Play the video.
void Seek(int64_t new_frame)
Seek to a specific frame in the player.
This namespace is the default namespace for all code in the openshot library.
openshot::PlaybackMode Mode()
Get the current mode.
void Stop()
Stop the video player and clear the cached frames.