connected stop, previous and next button;
STILL MISSING: check whether there is a next/previous medium and only then show/enable buttons
This commit is contained in:
parent
d6c806d41d
commit
61b8734b62
4 changed files with 33 additions and 4 deletions
|
|
@ -62,7 +62,7 @@ Item{
|
|||
// visible: model.pHasPrevious
|
||||
|
||||
onClicked:{
|
||||
//musicModel.playPrevious();
|
||||
musicModel.playPrevious();
|
||||
}
|
||||
}
|
||||
RoundButton{
|
||||
|
|
@ -87,8 +87,8 @@ Item{
|
|||
imageSource: "qrc:/icon_stop"
|
||||
|
||||
onClicked:{
|
||||
//musicModel.stop();
|
||||
//playPause.imageSource = "qrc:/icon_play"
|
||||
musicModel.stopMusic();
|
||||
playPause.imageSource = "qrc:/icon_play"
|
||||
}
|
||||
}
|
||||
RoundButton{
|
||||
|
|
@ -101,7 +101,7 @@ Item{
|
|||
// visible: model.pHasNext
|
||||
|
||||
onClicked:{
|
||||
//musicModel.playNext();
|
||||
musicModel.playNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ MusicController::MusicController(QObject *parent) : QObject(parent)
|
|||
|
||||
connect(mModel, &MusicModel::navigateTo, this, &MusicController::navigateTo);
|
||||
connect(mModel, &MusicModel::play, mPlayer, &VlcMediaListPlayer::play);
|
||||
connect(mModel, &MusicModel::stop, mPlayer, &VlcMediaListPlayer::stop);
|
||||
connect(mModel, &MusicModel::previous, mPlayer, &VlcMediaListPlayer::previous);
|
||||
connect(mModel, &MusicModel::next, mPlayer, &VlcMediaListPlayer::next);
|
||||
connect(mModel, &MusicModel::pause, mPlayer->mediaPlayer(), &VlcMediaPlayer::pause);
|
||||
connect(mModel, &MusicModel::navigateTo, [this](NavigationItemModel*){
|
||||
if(mModel->isPlaying()) mModel->playPause();
|
||||
|
|
|
|||
|
|
@ -49,6 +49,24 @@ void MusicModel::playPause()
|
|||
emit pause();
|
||||
}
|
||||
|
||||
void MusicModel::stopMusic()
|
||||
{
|
||||
if(mIsPlaying){
|
||||
mIsPlaying = false;
|
||||
emit stop();
|
||||
}
|
||||
}
|
||||
|
||||
void MusicModel::playNext()
|
||||
{
|
||||
emit next();
|
||||
}
|
||||
|
||||
void MusicModel::playPrevious()
|
||||
{
|
||||
emit previous();
|
||||
}
|
||||
|
||||
NavigationItemModel *MusicModel::getCurrentItem()
|
||||
{
|
||||
return mCurrentItem;
|
||||
|
|
|
|||
|
|
@ -11,12 +11,17 @@ class MusicModel : public QObject
|
|||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QObject* pCurrentItem READ getCurrentItem NOTIFY currentItemChanged)
|
||||
//Q_PROPERTY(QObject* pHasNext READ hasNext NOTIFY hasNextChanged)
|
||||
//Q_PROPERTY(QObject* pHasPrevious READ hasPrevious NOTIFY hasPreviousChanged)
|
||||
|
||||
signals:
|
||||
void navigateTo(NavigationItemModel *item);
|
||||
void currentItemChanged();
|
||||
void play();
|
||||
void pause();
|
||||
void stop();
|
||||
void previous();
|
||||
void next();
|
||||
|
||||
public:
|
||||
MusicModel(VlcInstance* instance, QObject *parent = Q_NULLPTR);
|
||||
|
|
@ -26,6 +31,9 @@ public:
|
|||
|
||||
Q_INVOKABLE void navigateBack();
|
||||
Q_INVOKABLE void playPause();
|
||||
Q_INVOKABLE void stopMusic();
|
||||
Q_INVOKABLE void playNext();
|
||||
Q_INVOKABLE void playPrevious();
|
||||
|
||||
NavigationItemModel *getCurrentItem();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue