29 #include "../../include/QtPlayer.h" 30 #include "../../include/Qt/PlayerDemo.h" 31 #include <QMessageBox> 32 #include <QFileDialog> 36 , vbox(new QVBoxLayout(this))
37 , menu(new QMenuBar(this))
39 , player(new
QtPlayer(video->GetRenderer()))
41 setWindowTitle(
"OpenShot Player");
43 menu->setNativeMenuBar(
false);
45 QAction *action = NULL;
46 action = menu->addAction(
"Choose File");
47 connect(action, SIGNAL(triggered(
bool)),
this, SLOT(open(
bool)));
49 vbox->addWidget(menu, 0);
50 vbox->addWidget(video, 1);
57 setFocusPolicy(Qt::StrongFocus);
68 QWidget *pWin = QApplication::activeWindow();
76 if (event->key() == Qt::Key_Space ||
event->key() == Qt::Key_K) {
87 if (player->
Speed() == 0)
97 else if (event->key() == Qt::Key_J) {
98 cout <<
"BACKWARD" << player->
Speed() - 1 << endl;
99 if (player->
Speed() - 1 != 0)
107 else if (event->key() == Qt::Key_L) {
108 cout <<
"FORWARD" << player->
Speed() + 1 << endl;
109 if (player->
Speed() + 1 != 0)
118 else if (event->key() == Qt::Key_Left) {
119 cout <<
"FRAME STEP -1" << endl;
120 if (player->
Speed() != 0)
124 else if (event->key() == Qt::Key_Right) {
125 cout <<
"FRAME STEP +1" << endl;
126 if (player->
Speed() != 0)
130 else if (event->key() == Qt::Key_Escape) {
131 cout <<
"QUIT PLAYER" << endl;
132 QWidget *pWin = QApplication::activeWindow();
137 QApplication::quit();
141 QWidget::keyPressEvent(event);
144 void PlayerDemo::open(
bool checked)
147 const QString filename = QFileDialog::getOpenFileName(
this,
"Open Video File");
148 if (filename.isEmpty())
return;
151 player->
SetSource(filename.toStdString());
void Seek(int64_t new_frame)
Seek to a specific frame in the player.
PlayerDemo(QWidget *parent=0)
This class is used to playback a video from a reader.
void Reader(ReaderBase *new_reader)
Set the current reader.
void keyPressEvent(QKeyEvent *event)
PlaybackMode Mode()
Get the current mode.
void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE
void Stop()
Stop the video player and clear the cached frames.
void Pause()
Pause the video.
Pause the video (holding the last displayed frame)
float Speed()
Get the Playback speed.
int Position()
Get the current frame number being played.
void Play()
Play the video.
void SetSource(const std::string &source)
Set the source URL/path of this player (which will create an internal Reader)