| 1 | /* This file is part of the KDE project. |
| 2 | * |
| 3 | * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
| 4 | * Copyright (C) 2013 Martin Sandsmark <martin.sandsmark@kde.org> |
| 5 | * |
| 6 | * This library is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU Lesser General Public License as published by |
| 8 | * the Free Software Foundation, either version 2.1 or 3 of the License. |
| 9 | * |
| 10 | * This library is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU Lesser General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Lesser General Public License |
| 16 | * along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 17 | */ |
| 18 | |
| 19 | #ifndef PHONON_VLC_VOLUMEFADEREFFECT_H |
| 20 | #define PHONON_VLC_VOLUMEFADEREFFECT_H |
| 21 | |
| 22 | #include <phonon/volumefaderinterface.h> |
| 23 | |
| 24 | #include <QtCore/QTime> |
| 25 | #include <QtCore/QPointer> |
| 26 | |
| 27 | #include "sinknode.h" |
| 28 | |
| 29 | class QTimeLine; |
| 30 | |
| 31 | namespace Phonon { |
| 32 | |
| 33 | class MediaObject; |
| 34 | |
| 35 | namespace VLC { |
| 36 | |
| 37 | class VolumeFaderEffect : public QObject, public SinkNode, public VolumeFaderInterface |
| 38 | { |
| 39 | Q_OBJECT |
| 40 | Q_INTERFACES(Phonon::VolumeFaderInterface) |
| 41 | |
| 42 | public: |
| 43 | explicit VolumeFaderEffect(QObject *parent = nullptr); |
| 44 | ~VolumeFaderEffect() override; |
| 45 | |
| 46 | // VolumeFaderInterface: |
| 47 | float volume() const override; |
| 48 | Phonon::VolumeFaderEffect::FadeCurve fadeCurve() const override; |
| 49 | void setFadeCurve(Phonon::VolumeFaderEffect::FadeCurve fadeCurve) override; |
| 50 | void fadeTo(float volume, int fadeTime) override; |
| 51 | void setVolume(float v) override; |
| 52 | QPointer<MediaObject> mediaObject() { return m_mediaObject; } |
| 53 | |
| 54 | private Q_SLOTS: |
| 55 | void slotSetVolume(qreal v); |
| 56 | |
| 57 | private: |
| 58 | void abortFade(); |
| 59 | inline void setVolumeInternal(float v); |
| 60 | |
| 61 | Phonon::VolumeFaderEffect::FadeCurve m_fadeCurve; |
| 62 | float m_fadeFromVolume; |
| 63 | float m_fadeToVolume; |
| 64 | QTimeLine *m_fadeTimeline; |
| 65 | |
| 66 | }; |
| 67 | |
| 68 | } // namespace VLC |
| 69 | } // namespace Phonon |
| 70 | |
| 71 | #endif // PHONON_VLC_VOLUMEFADEREFFECT_H |
| 72 | |