2 * Copyright (C) 2013-2016 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 * Author: Michael Zanetti <michael.zanetti@canonical.com>
21Audio::Audio(QObject* parent):
23 m_playbackState(StoppedState),
26 qsrand(time(nullptr));
27 m_timer.setInterval(1000);
28 connect(&m_timer, &QTimer::timeout, this, &Audio::timerEvent);
31 Q_EMIT positionChanged(m_position);
33 m_duration = (qrand() % 20000) + 10000;
34 Q_EMIT durationChanged(m_duration);
37QUrl Audio::source() const
42void Audio::setSource(const QUrl &source)
44 if (m_source != source) {
46 Q_EMIT sourceChanged(source);
50Audio::PlaybackState Audio::playbackState() const
52 return m_playbackState;
55int Audio::position() const
60int Audio::duration() const
65QString Audio::errorString() const
72 if (m_playbackState == PlayingState) {
73 m_playbackState = PausedState;
74 Q_EMIT playbackStateChanged(m_playbackState);
81 if (m_playbackState != PlayingState) {
82 m_playbackState = PlayingState;
83 Q_EMIT playbackStateChanged(m_playbackState);
91 if (m_playbackState != StoppedState) {
92 m_playbackState = StoppedState;
93 Q_EMIT playbackStateChanged(m_playbackState);
96 Q_EMIT positionChanged(m_position);
100void Audio::timerEvent()
102 if (m_position + 1000 < m_duration) {
104 Q_EMIT positionChanged(m_position);
110Audio::AudioRole Audio::audioRole() const
112 return Audio::MusicRole;
115void Audio::setAudioRole(Audio::AudioRole audioRole)
120DeclarativePlaylist *Audio::playlist() const
125void Audio::setPlaylist(DeclarativePlaylist *playlist)
127 if (playlist == m_playlist)
130 m_playlist = playlist;
131 Q_EMIT playlistChanged();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list