Commit b3981a9f authored by Camilo Higuita's avatar Camilo Higuita

pause/play track

parent d4e49b8d
......@@ -158,10 +158,18 @@ Kirigami.ApplicationWindow
ToolButton
{
id: playBtn
Icon{text: MdiFont.Icon.pause}
Icon {id: playIcon; text: MdiFont.Icon.play }
onClicked:
{
Player.pauseTrack()
if(player.isPaused())
{
Player.resumeTrack()
playIcon.text= MdiFont.Icon.pause
}else
{
Player.pauseTrack()
playIcon.text= MdiFont.Icon.play
}
}
}
......@@ -192,6 +200,8 @@ Kirigami.ApplicationWindow
onRowClicked:
{
Player.playTrack(model.get(index))
playIcon.text = MdiFont.Icon.pause
}
}
}
......
......@@ -50,6 +50,11 @@ int Player::duration()
return static_cast<int>(this->player->duration());
}
bool Player::isPaused()
{
return !(this->player->state() == QMediaPlayer::PlayingState);
}
void Player::update()
{
emit this->pos(static_cast<int>(static_cast<double>(this->player->position())/this->player->duration()*1000));
......
......@@ -17,6 +17,7 @@ public:
Q_INVOKABLE void stop();
Q_INVOKABLE void seek(const int &pos);
Q_INVOKABLE int duration();
Q_INVOKABLE bool isPaused();
private:
QMediaPlayer *player;
......
......@@ -3,6 +3,7 @@ function playTrack(track)
currentTrack = track
player.source(currentTrack.url);
player.play()
}
function pauseTrack()
......@@ -10,6 +11,11 @@ function pauseTrack()
player.pause()
}
function resumeTrack()
{
player.play()
}
function nextTrack()
{
var next = mainPlaylistTable.currentIndex+1 >= mainPlaylistTable.count? 0 : mainPlaylistTable.currentIndex+1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment