-/* $Id$
-
-This file is part of libmspal
-Copyright © 2009 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#include <algorithm>
#include <cstdlib>
#include <msp/core/except.h>
void Jukebox::add_track(const string &trk)
{
- bool was_empty=tracks.empty();
+ bool was_empty = tracks.empty();
tracks.push_back(trk);
if(was_empty)
{
- current_track=tracks.begin();
+ current_track = tracks.begin();
signal_track_changed.emit(*current_track);
}
}
void Jukebox::remove_track(const string &trk)
{
- list<string>::iterator i=find(tracks.begin(), tracks.end(), trk);
+ list<string>::iterator i = find(tracks.begin(), tracks.end(), trk);
if(i!=tracks.end())
{
if(i==current_track)
next();
tracks.erase(i);
if(tracks.empty())
- current_track=tracks.end();
+ current_track = tracks.end();
}
}
{
stop();
tracks.clear();
- current_track=tracks.end();
+ current_track = tracks.end();
}
const string &Jukebox::get_current_track() const
void Jukebox::set_shuffle(bool s)
{
- shuffle=s;
+ shuffle = s;
}
void Jukebox::play()
if(tracks.empty() || sound)
return;
- sound=new AL::Sound;
+ sound = new AL::Sound;
sound->open_file(*current_track);
streamer.play(*sound);
}
{
while(1)
{
- list<string>::iterator i=tracks.begin();
+ list<string>::iterator i = tracks.begin();
advance(i, rand()%tracks.size());
if(i!=current_track)
{
{
++current_track;
if(current_track==tracks.end())
- current_track=tracks.begin();
+ current_track = tracks.begin();
}
signal_track_changed.emit(*current_track);
}
if(tracks.size()>1)
{
if(current_track==tracks.begin())
- current_track=tracks.end();
+ current_track = tracks.end();
--current_track;
signal_track_changed.emit(*current_track);
}
{
streamer.stop();
delete sound;
- sound=0;
+ sound = 0;
}
void Jukebox::tick()