From: Mikko Rasa Date: Mon, 13 Dec 2010 10:06:24 +0000 (+0000) Subject: Add a previous() method to Jukebox X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=32f20df0174d2872199f6b14d65e0f0d7556adaa;p=libs%2Fal.git Add a previous() method to Jukebox --- diff --git a/source/jukebox.cpp b/source/jukebox.cpp index 391edd1..b8224b2 100644 --- a/source/jukebox.cpp +++ b/source/jukebox.cpp @@ -111,6 +111,22 @@ void Jukebox::next() play(); } +void Jukebox::previous() +{ + if(shuffle) + return next(); + + stop(); + if(tracks.size()>1) + { + if(current_track==tracks.begin()) + current_track=tracks.end(); + --current_track; + signal_track_changed.emit(*current_track); + } + play(); +} + void Jukebox::stop() { streamer.stop(); diff --git a/source/jukebox.h b/source/jukebox.h index 85a2b03..c4e0aaf 100644 --- a/source/jukebox.h +++ b/source/jukebox.h @@ -45,6 +45,7 @@ public: void play(); void next(); + void previous(); void stop(); void tick(); };