/**
 * audio_playlist.c: The audio playlist
 * 
 * Copyright: See COPYING file that comes with this distribution
 *
 * Author: Matthias Feistel <hitman_47@users.sourceforge.net>, (C) 2007
 */

#include "audio_playlist.h"
#include "web_serviceconnector.h" // cWebServiceConnector wc;
#include "settings.h" // cSettings::GetInstance().HandshakedataMap[ "session" ]
#include "web_serviceconnector_scrobbler.h" // cWebServiceConnectorScrobbler::Submission()
#include "audio_control.h" // cControl::Control()->GetIndex
#include <sstream>

cAudioPlaylist::cAudioPlaylist( )
{
}

cAudioPlaylist::~cAudioPlaylist( )
{
}

cAudioPlaylist *cAudioPlaylist::gpo_config = NULL;

cAudioPlaylist& cAudioPlaylist::GetInstance( void )
{
	if( NULL == gpo_config )
		gpo_config = new cAudioPlaylist();
	
	return *gpo_config;
}

std::string cAudioPlaylist::GetNextsongurl( void )
{
	std::string nextrack;
	
	
	// submit last song as it has been fully played and
	if( !trackList.empty( ) )
	{
		// delete previous first entry of queue
		trackList.pop( );
	}
	
	if( !trackList.empty( ) )
	{
		// present the next track as the first in the queue:
		nextrack = trackList.front().begin()->second[ "track_location" ];
	}
	else
	{
		cWebServiceConnector wc;
		wc.GetPlaylist( cSettings::GetInstance().HandshakedataMap[ "session" ] );
	}
	
	return nextrack;
}

int cAudioPlaylist::Clear( void )
{
	while( !trackList.empty( ) )
		trackList.pop( );
	
	return 0;
}
