BluezQt

declarativemediaplayer.cpp
1 /*
2  * BluezQt - Asynchronous Bluez wrapper library
3  *
4  * SPDX-FileCopyrightText: 2015 David Rosca <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
7  */
8 
9 #include "declarativemediaplayer.h"
10 
11 DeclarativeMediaPlayer::DeclarativeMediaPlayer(BluezQt::MediaPlayerPtr mediaPlayer, QObject *parent)
12  : QObject(parent)
13  , m_mediaPlayer(mediaPlayer)
14 {
15  connect(m_mediaPlayer.data(), &BluezQt::MediaPlayer::nameChanged, this, &DeclarativeMediaPlayer::nameChanged);
16  connect(m_mediaPlayer.data(), &BluezQt::MediaPlayer::equalizerChanged, this, &DeclarativeMediaPlayer::equalizerChanged);
17  connect(m_mediaPlayer.data(), &BluezQt::MediaPlayer::repeatChanged, this, &DeclarativeMediaPlayer::repeatChanged);
18  connect(m_mediaPlayer.data(), &BluezQt::MediaPlayer::shuffleChanged, this, &DeclarativeMediaPlayer::shuffleChanged);
19  connect(m_mediaPlayer.data(), &BluezQt::MediaPlayer::statusChanged, this, &DeclarativeMediaPlayer::statusChanged);
20  connect(m_mediaPlayer.data(), &BluezQt::MediaPlayer::positionChanged, this, &DeclarativeMediaPlayer::positionChanged);
21 
22  connect(m_mediaPlayer.data(), &BluezQt::MediaPlayer::trackChanged, this, [this]() {
23  updateTrack();
24  Q_EMIT trackChanged(m_track);
25  });
26 
27  updateTrack();
28 }
29 
30 QString DeclarativeMediaPlayer::name() const
31 {
32  return m_mediaPlayer->name();
33 }
34 
35 BluezQt::MediaPlayer::Equalizer DeclarativeMediaPlayer::equalizer() const
36 {
37  return m_mediaPlayer->equalizer();
38 }
39 
40 void DeclarativeMediaPlayer::setEqualizer(BluezQt::MediaPlayer::Equalizer equalizer)
41 {
42  m_mediaPlayer->setEqualizer(equalizer);
43 }
44 
45 BluezQt::MediaPlayer::Repeat DeclarativeMediaPlayer::repeat() const
46 {
47  return m_mediaPlayer->repeat();
48 }
49 
50 void DeclarativeMediaPlayer::setRepeat(BluezQt::MediaPlayer::Repeat repeat)
51 {
52  m_mediaPlayer->setRepeat(repeat);
53 }
54 
55 BluezQt::MediaPlayer::Shuffle DeclarativeMediaPlayer::shuffle() const
56 {
57  return m_mediaPlayer->shuffle();
58 }
59 
60 void DeclarativeMediaPlayer::setShuffle(BluezQt::MediaPlayer::Shuffle shuffle)
61 {
62  m_mediaPlayer->setShuffle(shuffle);
63 }
64 
65 BluezQt::MediaPlayer::Status DeclarativeMediaPlayer::status() const
66 {
67  return m_mediaPlayer->status();
68 }
69 
70 QJsonObject DeclarativeMediaPlayer::track() const
71 {
72  return m_track;
73 }
74 
75 quint32 DeclarativeMediaPlayer::position() const
76 {
77  return m_mediaPlayer->position();
78 }
79 
80 BluezQt::PendingCall *DeclarativeMediaPlayer::play()
81 {
82  return m_mediaPlayer->play();
83 }
84 
86 {
87  return m_mediaPlayer->pause();
88 }
89 
91 {
92  return m_mediaPlayer->stop();
93 }
94 
95 BluezQt::PendingCall *DeclarativeMediaPlayer::next()
96 {
97  return m_mediaPlayer->next();
98 }
99 
100 BluezQt::PendingCall *DeclarativeMediaPlayer::previous()
101 {
102  return m_mediaPlayer->previous();
103 }
104 
105 BluezQt::PendingCall *DeclarativeMediaPlayer::fastForward()
106 {
107  return m_mediaPlayer->fastForward();
108 }
109 
110 BluezQt::PendingCall *DeclarativeMediaPlayer::rewind()
111 {
112  return m_mediaPlayer->rewind();
113 }
114 
115 void DeclarativeMediaPlayer::updateTrack()
116 {
117  m_track[QStringLiteral("valid")] = m_mediaPlayer->track().isValid();
118  m_track[QStringLiteral("title")] = m_mediaPlayer->track().title();
119  m_track[QStringLiteral("artist")] = m_mediaPlayer->track().artist();
120  m_track[QStringLiteral("album")] = m_mediaPlayer->track().album();
121  m_track[QStringLiteral("genre")] = m_mediaPlayer->track().genre();
122  m_track[QStringLiteral("numberOfTracks")] = qint64(m_mediaPlayer->track().numberOfTracks());
123  m_track[QStringLiteral("trackNumber")] = qint64(m_mediaPlayer->track().trackNumber());
124  m_track[QStringLiteral("duration")] = qint64(m_mediaPlayer->track().duration());
125 }
Equalizer
Equalizer state.
Definition: mediaplayer.h:42
void stop(Ekos::AlignState mode)
void statusChanged(Status status)
Indicates that player's status have changed.
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void trackChanged(MediaPlayerTrack track)
Indicates that player's current track have changed.
void equalizerChanged(Equalizer equalizer)
Indicates that player's equalizer state have changed.
Repeat
Repeat state.
Definition: mediaplayer.h:51
void positionChanged(quint32 position)
Indicates that player's playback position have changed.
Q_SCRIPTABLE Q_NOREPLY void pause()
Shuffle
Shuffle state.
Definition: mediaplayer.h:64
void nameChanged(const QString &name)
Indicates that player's name have changed.
void shuffleChanged(Shuffle shuffle)
Indicates that player's shuffle state have changed.
Status
Player status.
Definition: mediaplayer.h:75
void repeatChanged(Repeat repeat)
Indicates that player's repeat state have changed.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 04:19:10 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.