From 0b4e388d88af73c9f542289d40b261cd32116380 Mon Sep 17 00:00:00 2001 From: Nicholas Young Date: Tue, 23 Feb 2010 14:52:03 +1000 Subject: Player demo updated with more user-friendly previous button behaviour. Pressing previous within the first five seconds will go to the previous item in the playlist. Otherwise, it will seek to the beginning of the current item. Reviewed-by: Kurt Korbatits --- demos/multimedia/player/player.cpp | 12 +++++++++++- demos/multimedia/player/player.h | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'demos') diff --git a/demos/multimedia/player/player.cpp b/demos/multimedia/player/player.cpp index 64b1f256bd..49d18cbbbb 100644 --- a/demos/multimedia/player/player.cpp +++ b/demos/multimedia/player/player.cpp @@ -99,7 +99,7 @@ Player::Player(QWidget *parent) connect(controls, SIGNAL(pause()), player, SLOT(pause())); connect(controls, SIGNAL(stop()), player, SLOT(stop())); connect(controls, SIGNAL(next()), playlist, SLOT(next())); - connect(controls, SIGNAL(previous()), playlist, SLOT(previous())); + connect(controls, SIGNAL(previous()), this, SLOT(previousClicked())); connect(controls, SIGNAL(changeVolume(int)), player, SLOT(setVolume(int))); connect(controls, SIGNAL(changeMuting(bool)), player, SLOT(setMuted(bool))); connect(controls, SIGNAL(changeRate(qreal)), player, SLOT(setPlaybackRate(qreal))); @@ -200,6 +200,16 @@ void Player::metaDataChanged() } } +void Player::previousClicked() +{ + // Go to previous track if we are within the first 5 seconds of playback + // Otherwise, seek to the beginning. + if(player->position() <= 5000) + playlist->previous(); + else + player->setPosition(0); +} + void Player::jump(const QModelIndex &index) { if (index.isValid()) { diff --git a/demos/multimedia/player/player.h b/demos/multimedia/player/player.h index 0ad609b4a4..1de8b1a21d 100644 --- a/demos/multimedia/player/player.h +++ b/demos/multimedia/player/player.h @@ -77,6 +77,8 @@ private slots: void positionChanged(qint64 progress); void metaDataChanged(); + void previousClicked(); + void seek(int seconds); void jump(const QModelIndex &index); void playlistPositionChanged(int); -- cgit v1.2.1