Add volume control

This commit is contained in:
Anika Raemer 2021-03-14 14:42:32 +01:00
parent 5d5e3c6888
commit 4a83f971f3
14 changed files with 144 additions and 32 deletions

View file

@ -18,6 +18,7 @@ class MusicModel : public QObject
Q_PROPERTY(QString pMediaLength READ getMediaLength NOTIFY mediaLengthChanged)
Q_PROPERTY(QString pTime READ getTime NOTIFY progressChanged)
Q_PROPERTY(QString pMediaTitle READ getMediaTitle NOTIFY mediaTitleChanged)
Q_PROPERTY(int pAudioVolume READ getAudioVolume WRITE setAudioVolume NOTIFY audioVolumeChanged)
signals:
void navigateTo(NavigationItemModel *item);
@ -33,6 +34,7 @@ signals:
void progressChanged();
void mediaLengthChanged();
void mediaTitleChanged();
void audioVolumeChanged(int newVolume);
public:
MusicModel(VlcInstance* instance, QObject *parent = Q_NULLPTR);
@ -54,6 +56,15 @@ public:
bool hasNext() const;
bool hasPrevious() const;
inline int getAudioVolume() const { return mAudioVolume; }
/**
* @brief Set audio volume. Information is transferred to VlcAudio
* @param newVolume value between 0 and 100 (audio level in percent)
* Ensures that volume is inbetween 0 and 100. If this range is exceeded,
* the volume is set to the lowest and highest allowed value, respectively.
*/
void setAudioVolume(int newVolume);
double getProgress() const;
QString getMediaTitle() const;
@ -79,10 +90,11 @@ private:
int mCurrentMediaItemLength = 0;
int mCurrentTime = 0;
double mCurrentMediaItemProgress = 0;
int mAudioVolume{50};
QString mMediaTitle = QString("");
NavigationItemModel* mCurrentItem = Q_NULLPTR;
VlcMediaList* mMedia = Q_NULLPTR;
VlcInstance* mVlc;
VlcInstance* mVlc = Q_NULLPTR;
};
#endif // MUSICMODEL_H