BluezQt

declarativemediaplayer.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 "declarativemediaplayer.h"
10
11DeclarativeMediaPlayer::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
30QString DeclarativeMediaPlayer::name() const
31{
32 return m_mediaPlayer->name();
33}
34
35BluezQt::MediaPlayer::Equalizer DeclarativeMediaPlayer::equalizer() const
36{
37 return m_mediaPlayer->equalizer();
38}
39
40void DeclarativeMediaPlayer::setEqualizer(BluezQt::MediaPlayer::Equalizer equalizer)
41{
42 m_mediaPlayer->setEqualizer(equalizer);
43}
44
45BluezQt::MediaPlayer::Repeat DeclarativeMediaPlayer::repeat() const
46{
47 return m_mediaPlayer->repeat();
48}
49
50void DeclarativeMediaPlayer::setRepeat(BluezQt::MediaPlayer::Repeat repeat)
51{
52 m_mediaPlayer->setRepeat(repeat);
53}
54
55BluezQt::MediaPlayer::Shuffle DeclarativeMediaPlayer::shuffle() const
56{
57 return m_mediaPlayer->shuffle();
58}
59
60void DeclarativeMediaPlayer::setShuffle(BluezQt::MediaPlayer::Shuffle shuffle)
61{
62 m_mediaPlayer->setShuffle(shuffle);
63}
64
65BluezQt::MediaPlayer::Status DeclarativeMediaPlayer::status() const
66{
67 return m_mediaPlayer->status();
68}
69
70QJsonObject DeclarativeMediaPlayer::track() const
71{
72 return m_track;
73}
74
75quint32 DeclarativeMediaPlayer::position() const
76{
77 return m_mediaPlayer->position();
78}
79
80BluezQt::PendingCall *DeclarativeMediaPlayer::play()
81{
82 return m_mediaPlayer->play();
83}
84
85BluezQt::PendingCall *DeclarativeMediaPlayer::pause()
86{
87 return m_mediaPlayer->pause();
88}
89
90BluezQt::PendingCall *DeclarativeMediaPlayer::stop()
91{
92 return m_mediaPlayer->stop();
93}
94
95BluezQt::PendingCall *DeclarativeMediaPlayer::next()
96{
97 return m_mediaPlayer->next();
98}
99
100BluezQt::PendingCall *DeclarativeMediaPlayer::previous()
101{
102 return m_mediaPlayer->previous();
103}
104
105BluezQt::PendingCall *DeclarativeMediaPlayer::fastForward()
106{
107 return m_mediaPlayer->fastForward();
108}
109
110BluezQt::PendingCall *DeclarativeMediaPlayer::rewind()
111{
112 return m_mediaPlayer->rewind();
113}
114
115void 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}
126
127#include "moc_declarativemediaplayer.cpp"
Repeat
Repeat state.
Definition mediaplayer.h:53
void equalizerChanged(Equalizer equalizer)
Indicates that player's equalizer state have changed.
Shuffle
Shuffle state.
Definition mediaplayer.h:66
void trackChanged(MediaPlayerTrack track)
Indicates that player's current track have changed.
Equalizer
Equalizer state.
Definition mediaplayer.h:44
Status
Player status.
Definition mediaplayer.h:77
void shuffleChanged(Shuffle shuffle)
Indicates that player's shuffle state have changed.
void repeatChanged(Repeat repeat)
Indicates that player's repeat state have changed.
void positionChanged(quint32 position)
Indicates that player's playback position have changed.
void nameChanged(const QString &name)
Indicates that player's name have changed.
void statusChanged(Status status)
Indicates that player's status have changed.
Pending method call.
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:46:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.