#include <algorithm>
#include <cstdlib>
+#include <msp/core/except.h>
#include "jukebox.h"
#include "sound.h"
Jukebox::Jukebox():
streamer(source),
sound(0),
+ current_track(tracks.end()),
shuffle(false)
{ }
bool was_empty=tracks.empty();
tracks.push_back(trk);
if(was_empty)
+ {
current_track=tracks.begin();
+ signal_track_changed.emit(*current_track);
+ }
}
void Jukebox::remove_track(const string &trk)
if(i==current_track)
next();
tracks.erase(i);
+ if(tracks.empty())
+ current_track=tracks.end();
}
}
{
stop();
tracks.clear();
+ current_track=tracks.end();
+}
+
+const string &Jukebox::get_current_track() const
+{
+ if(tracks.empty())
+ throw InvalidState("No current track");
+ return *current_track;
}
void Jukebox::set_shuffle(bool s)
if(current_track==tracks.end())
current_track=tracks.begin();
}
+ signal_track_changed.emit(*current_track);
}
play();
}
#include <list>
#include <string>
+#include <sigc++/signal.h>
#include "source.h"
#include "streamer.h"
class Jukebox
{
+public:
+ sigc::signal<void, const std::string &> signal_track_changed;
+
private:
Source source;
Streamer streamer;
void add_track(const std::string &);
void remove_track(const std::string &);
void clear_tracks();
+ const std::string &get_current_track() const;
void set_shuffle(bool);
void play();