1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "omxplayer.h"
#include <QFile>
#include <QDebug>
#include "systemutils.h"
// TODO get rid of all the redunant stuff from mplayer and merge it into 1 base
Omxplayer::Omxplayer(Library& library, const BaseConfig& snapshotConfig) :
VideoPlayer(library, snapshotConfig) {
}
bool Omxplayer::playFileImpl(QString filepath, const TvShowPlayerSettings&) {
if (!QFile::exists(filepath)) {
qDebug() << "can not play: file does not exists. Is the drive connected?" << filepath;
}
pauseStatus = false;
QStringList args;
args.append("-t");
args.append("0");
args.append(filepath);
process.start("omxplayer", args);
process.waitForStarted();
SystemUtils::setProcessPriority(process, -20);
if (process.state() == QProcess::NotRunning) {
return false;
}
return true;
}
void Omxplayer::pauseImpl() {
if (!pauseStatus) {
process.write("p");
pauseStatus = true;
}
}
void Omxplayer::unPauseImpl() {
if (pauseStatus) {
process.write("p");
}
}
void Omxplayer::stop() {
process.write("q");
pauseStatus = true;
}
void Omxplayer::backwards(const int) {
const int key = 0x5b44; // key left
process.write((const char*)&key, sizeof(key));
}
void Omxplayer::forwards(const int) {
const int key = 0x5b43; // key right
process.write((const char*)&key, sizeof(key));
}
float Omxplayer::incrementVolume() {
process.write("+");
return -1;
}
float Omxplayer::decrementVolume() {
process.write("-");
return -1;
}