32 #include "../../include/QtPlayer.h" 33 #include "../../include/Qt/PlayerDemo.h" 34 #include <QMessageBox> 35 #include <QFileDialog> 39 , vbox(new QVBoxLayout(this))
40 , menu(new QMenuBar(this))
42 , player(new
openshot::QtPlayer(video->GetRenderer()))
44 setWindowTitle(
"OpenShot Player");
46 menu->setNativeMenuBar(
false);
48 QAction *action = NULL;
49 action = menu->addAction(
"Choose File");
50 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(open(
bool)));
52 vbox->addWidget(menu, 0);
53 vbox->addWidget(video, 1);
60 setFocusPolicy(Qt::StrongFocus);
71 QWidget *pWin = QApplication::activeWindow();
79 if (event->key() == Qt::Key_Space ||
event->key() == Qt::Key_K) {
90 if (player->
Speed() == 0)
100 else if (event->key() == Qt::Key_J) {
101 std::cout <<
"BACKWARD" << player->
Speed() - 1 << std::endl;
102 if (player->
Speed() - 1 != 0)
110 else if (event->key() == Qt::Key_L) {
111 std::cout <<
"FORWARD" << player->
Speed() + 1 << std::endl;
112 if (player->
Speed() + 1 != 0)
121 else if (event->key() == Qt::Key_Left) {
122 std::cout <<
"FRAME STEP -1" << std::endl;
123 if (player->
Speed() != 0)
127 else if (event->key() == Qt::Key_Right) {
128 std::cout <<
"FRAME STEP +1" << std::endl;
129 if (player->
Speed() != 0)
133 else if (event->key() == Qt::Key_Escape) {
134 std::cout <<
"QUIT PLAYER" << std::endl;
135 QWidget *pWin = QApplication::activeWindow();
140 QApplication::quit();
144 QWidget::keyPressEvent(event);
147 void PlayerDemo::open(
bool checked)
150 const QString filename = QFileDialog::getOpenFileName(
this,
"Open Video File");
151 if (filename.isEmpty())
return;
154 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
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.