X-Git-Url: http://git.maemo.org/git/?p=someplayer;a=blobdiff_plain;f=src%2Fplayer%2Fplayer.cpp;h=0f11f9df6e5e705c988ffd5f872ff22dce1da9f9;hp=7eecd0eaffbc4b1697b72007615c5fada576a2d4;hb=c5dac101a0ecbf2872c00fa48b95f59ce39ef9cf;hpb=e0bce0a80c207c746ef2e5de527d7919e63252f7 diff --git a/src/player/player.cpp b/src/player/player.cpp index 7eecd0e..0f11f9d 100644 --- a/src/player/player.cpp +++ b/src/player/player.cpp @@ -17,6 +17,7 @@ Player::Player(QObject *parent) : qsrand(seed); _random = false; _repeat = false; + _current = -1; } void Player::setTrackId(int id) { @@ -55,6 +56,8 @@ void Player::next() { _history.push(_current % count); if (!_queue.isEmpty()) { _current = _queue.dequeue(); + } else if (!_prev_history.isEmpty()) { + _current = _prev_history.pop(); } else { if (_random) { _current = (count + (qrand() + qrand() + qrand()) % count) % count; @@ -81,7 +84,7 @@ void Player::_set_source() { void Player::prev() { if (_history.count() > 0) { - _queue.push_front(_current); + _prev_history.push(_current); _current = _history.pop(); _track = _playlist.tracks().at(_current); } @@ -137,9 +140,14 @@ void Player::seek(int s) { } void Player::play() { - _player->play(); _state = PLAYER_PLAYING; emit stateChanged(_state); + if (_current == -1) { + _current = 0; + _track = _playlist.tracks().at(0); + _set_source(); + } + _player->play(); } void Player::enqueue(int id) {