This repository has been archived by the owner on Jul 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
VlcPlayer.cpp
49 lines (36 loc) · 1.5 KB
/
VlcPlayer.cpp
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
/*
Copyright © 2009, 2010, 2011 Vladimír Vondruš <mosra@centrum.cz>
Copyright © 2010 Jan Dupal <dupal.j@seznam.cz>
This file is part of HeyTrack.
HeyTrack is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License version 3
only, as published by the Free Software Foundation.
HeyTrack is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License version 3 for more details.
*/
#include "VlcPlayer.h"
#include <QtDBus/QDBusInterface>
#include <QtDBus/QDBusReply>
#include "Mpris1.h"
namespace HeyTrack { namespace Core {
VlcPlayer::VlcPlayer(QObject* parent): AbstractPlayer(parent) {
playerInterface = new QDBusInterface("org.mpris.MediaPlayer2.vlc", "/Player", "", QDBusConnection::sessionBus(), this);
tracklistInterface = new QDBusInterface("org.mpris.MediaPlayer2.vlc", "/TrackList", "", QDBusConnection::sessionBus(), this);
}
bool VlcPlayer::isPlaying() {
/** @todo wtf Mpris1 */
QDBusReply<Mpris1::Status> reply = playerInterface->call("PlaybackStatus");
if(reply.isValid())
return reply.value().play == 0;
return false;
}
void VlcPlayer::play(const QString& url) {
/* Add track and start playing immediately */
tracklistInterface->call("AddTrack", url, true);
}
void VlcPlayer::stop() {
playerInterface->call("Stop");
}
}}