1
0
Fork 0

[Backend] Added seekAbsolute.

This commit is contained in:
Kitteh 2018-11-08 13:31:14 +00:00
parent 02750f65db
commit 63eff586b0
3 changed files with 12 additions and 3 deletions

View file

@ -269,6 +269,12 @@ MpvPlayerBackend::addVolume(const QVariant& volume)
<< "volume" << volume); << "volume" << volume);
} }
void
MpvPlayerBackend::seekAbsolute(const QVariant& seekTime)
{
command(QVariantList() << "seek" << seekTime << "absolute");
}
void void
MpvPlayerBackend::seek(const QVariant& seekTime) MpvPlayerBackend::seek(const QVariant& seekTime)
{ {
@ -393,6 +399,7 @@ MpvPlayerBackend::handle_mpv_event(mpv_event* event)
} else if (strcmp(prop->name, "duration") == 0) { } else if (strcmp(prop->name, "duration") == 0) {
if (prop->format == MPV_FORMAT_DOUBLE) { if (prop->format == MPV_FORMAT_DOUBLE) {
double time = *(double*)prop->data; double time = *(double*)prop->data;
updateDurationStringText();
findChild<QObject*>("progressBar")->setProperty("to", time); findChild<QObject*>("progressBar")->setProperty("to", time);
} }
} else if (strcmp(prop->name, "volume") == 0) { } else if (strcmp(prop->name, "volume") == 0) {
@ -424,6 +431,7 @@ MpvPlayerBackend::handle_mpv_event(mpv_event* event)
updatePrev(QVariant(pos)); updatePrev(QVariant(pos));
} }
} else if (strcmp(prop->name, "pause") == 0) { } else if (strcmp(prop->name, "pause") == 0) {
qDebug() << prop->data;
updatePlayPause(getProperty("pause")); updatePlayPause(getProperty("pause"));
} else if (strcmp(prop->name, "tracks-menu") == 0) { } else if (strcmp(prop->name, "tracks-menu") == 0) {
QMetaObject::invokeMethod(this, "tracksUpdate"); QMetaObject::invokeMethod(this, "tracksUpdate");

View file

@ -49,6 +49,7 @@ public slots:
void addVolume(const QVariant& volume); void addVolume(const QVariant& volume);
void loadFile(const QVariant& filename); void loadFile(const QVariant& filename);
void seek(const QVariant& seekTime); void seek(const QVariant& seekTime);
void seekAbsolute(const QVariant& seekTime);
void command(const QVariant& params); void command(const QVariant& params);
void setProperty(const QString& name, const QVariant& value); void setProperty(const QString& name, const QVariant& value);
void setOption(const QString& name, const QVariant& value); void setOption(const QString& name, const QVariant& value);

View file

@ -173,7 +173,7 @@ ApplicationWindow {
if (val != 0) { if (val != 0) {
skipto = Math.floor(progressBar.to / 9 * val) skipto = Math.floor(progressBar.to / 9 * val)
} }
player.command(["seek", skipto, "absolute"]) player.seekAbsolute(skipto)
} }
function isAnyMenuOpen() { function isAnyMenuOpen() {
@ -945,7 +945,7 @@ ApplicationWindow {
bottomPadding: 0 bottomPadding: 0
onMoved: { onMoved: {
player.command(["seek", progressBar.value, "absolute"]) player.seekAbsolute(progressBar.value)
} }
function getProgressBarHeight(nyan, isMouse) { function getProgressBarHeight(nyan, isMouse) {
@ -999,7 +999,7 @@ ApplicationWindow {
z: 10 z: 10
radius: height radius: height
anchors.left: progressLength.right anchors.left: progressLength.right
anchors.leftMargin: progressBar.handle.width - 2 anchors.leftMargin: 2
//anchors.left: progressBar.handle.horizontalCenter //anchors.left: progressBar.handle.horizontalCenter
anchors.bottom: progressBar.background.bottom anchors.bottom: progressBar.background.bottom
anchors.top: progressBar.background.top anchors.top: progressBar.background.top