BluezQt

mediaplayer.cpp
1/*
2 * BluezQt - Asynchronous Bluez wrapper library
3 *
4 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7 */
8
9#include "mediaplayer.h"
10#include "mediaplayer_p.h"
11#include "pendingcall.h"
12
13namespace BluezQt
14{
15static QString equalizerToString(MediaPlayer::Equalizer equalizer)
16{
17 switch (equalizer) {
19 return QStringLiteral("on");
20 default:
21 return QStringLiteral("off");
22 }
23}
24
25static QString repeatToString(MediaPlayer::Repeat repeat)
26{
27 switch (repeat) {
29 return QStringLiteral("singletrack");
31 return QStringLiteral("alltracks");
33 return QStringLiteral("group");
34 default:
35 return QStringLiteral("off");
36 }
37}
38
39static QString shuffleToString(MediaPlayer::Shuffle shuffle)
40{
41 switch (shuffle) {
43 return QStringLiteral("alltracks");
45 return QStringLiteral("group");
46 default:
47 return QStringLiteral("off");
48 }
49}
50
51MediaPlayer::MediaPlayer(const QString &path, const QVariantMap &properties)
52 : QObject()
53 , d(new MediaPlayerPrivate(path, properties))
54{
55}
56
57MediaPlayer::~MediaPlayer() = default;
58
59MediaPlayerPtr MediaPlayer::toSharedPtr() const
60{
61 return d->q.toStrongRef();
62}
63
64QString MediaPlayer::name() const
65{
66 return d->m_name;
67}
68
69MediaPlayer::Equalizer MediaPlayer::equalizer() const
70{
71 return d->m_equalizer;
72}
73
74PendingCall *MediaPlayer::setEqualizer(MediaPlayer::Equalizer equalizer)
75{
76 return new PendingCall(d->setDBusProperty(QStringLiteral("Equalizer"), equalizerToString(equalizer)), PendingCall::ReturnVoid, this);
77}
78
79MediaPlayer::Repeat MediaPlayer::repeat() const
80{
81 return d->m_repeat;
82}
83
84PendingCall *MediaPlayer::setRepeat(MediaPlayer::Repeat repeat)
85{
86 return new PendingCall(d->setDBusProperty(QStringLiteral("Repeat"), repeatToString(repeat)), PendingCall::ReturnVoid, this);
87}
88
89MediaPlayer::Shuffle MediaPlayer::shuffle() const
90{
91 return d->m_shuffle;
92}
93
94PendingCall *MediaPlayer::setShuffle(MediaPlayer::Shuffle shuffle)
95{
96 return new PendingCall(d->setDBusProperty(QStringLiteral("Shuffle"), shuffleToString(shuffle)), PendingCall::ReturnVoid, this);
97}
98
99MediaPlayer::Status MediaPlayer::status() const
100{
101 return d->m_status;
102}
103
104MediaPlayerTrack MediaPlayer::track() const
105{
106 return d->m_track;
107}
108
109quint32 MediaPlayer::position() const
110{
111 return d->m_position;
112}
113
114PendingCall *MediaPlayer::play()
115{
116 return new PendingCall(d->m_bluezMediaPlayer->Play(), PendingCall::ReturnVoid, this);
117}
118
119PendingCall *MediaPlayer::pause()
120{
121 return new PendingCall(d->m_bluezMediaPlayer->Pause(), PendingCall::ReturnVoid, this);
122}
123
124PendingCall *MediaPlayer::stop()
125{
126 return new PendingCall(d->m_bluezMediaPlayer->Stop(), PendingCall::ReturnVoid, this);
127}
128
129PendingCall *MediaPlayer::next()
130{
131 return new PendingCall(d->m_bluezMediaPlayer->Next(), PendingCall::ReturnVoid, this);
132}
133
134PendingCall *MediaPlayer::previous()
135{
136 return new PendingCall(d->m_bluezMediaPlayer->Previous(), PendingCall::ReturnVoid, this);
137}
138
139PendingCall *MediaPlayer::fastForward()
140{
141 return new PendingCall(d->m_bluezMediaPlayer->FastForward(), PendingCall::ReturnVoid, this);
142}
143
144PendingCall *MediaPlayer::rewind()
145{
146 return new PendingCall(d->m_bluezMediaPlayer->Rewind(), PendingCall::ReturnVoid, this);
147}
148
149} // namespace BluezQt
150
151#include "moc_mediaplayer.cpp"
Media player track.
Repeat
Repeat state.
Definition mediaplayer.h:53
@ RepeatGroup
Repeat group.
Definition mediaplayer.h:61
@ RepeatSingleTrack
Repeat single track.
Definition mediaplayer.h:57
@ RepeatAllTracks
Repeat all tracks.
Definition mediaplayer.h:59
Shuffle
Shuffle state.
Definition mediaplayer.h:66
@ ShuffleGroup
Shuffle group.
Definition mediaplayer.h:72
@ ShuffleAllTracks
Shuffle all tracks.
Definition mediaplayer.h:70
Equalizer
Equalizer state.
Definition mediaplayer.h:44
@ EqualizerOn
Equalizer on.
Definition mediaplayer.h:46
Status
Player status.
Definition mediaplayer.h:77
Pending method call.
QString path(const QString &relativePath)
KGuiItem properties()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:00:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.