2009-01-03 01:38:44 +00:00
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Include
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
#include <iostream> // System
|
|
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
|
#include "Common.h" // Global common
|
|
|
|
|
#include "ConsoleWindow.h"
|
2009-01-05 07:02:24 +00:00
|
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
|
//#include "../../Common/Src/Console.h" // Local common
|
2009-01-03 01:38:44 +00:00
|
|
|
|
|
|
|
|
|
#include "OutputPlugin.h" // Local
|
|
|
|
|
#include "Playback.h"
|
|
|
|
|
#include "Playlist.h"
|
|
|
|
|
|
|
|
|
|
#define _DLL_PLAYER_H_
|
|
|
|
|
#include "PlayerExport.h" // DLL Player
|
|
|
|
|
//////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Declarations and definitions
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
std::string CurrentlyPlayingFile;
|
2009-01-05 07:02:24 +00:00
|
|
|
|
int GlobalVolume = -1;
|
|
|
|
|
bool GlobalMute = false;
|
2009-01-03 01:38:44 +00:00
|
|
|
|
bool GlobalPause;
|
|
|
|
|
bool TimerCreated = false;
|
|
|
|
|
bool Initialized = false;
|
|
|
|
|
/////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------
|
2009-01-17 14:28:09 +00:00
|
|
|
|
/* We keep the file in the playlist, even though we currently only ever have one file here
|
2009-01-03 01:38:44 +00:00
|
|
|
|
at a time */
|
|
|
|
|
// ---------
|
|
|
|
|
void AddFileToPlaylist(char * a)
|
|
|
|
|
{
|
|
|
|
|
//playlist->RemoveAll();
|
|
|
|
|
|
|
|
|
|
#include "unicode.h"
|
|
|
|
|
const int iLen = strlen(a); // I can't do this because I don't
|
|
|
|
|
|
|
|
|
|
printf( "iLen <%i>\n", iLen );
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
// Do some string conversion
|
|
|
|
|
TCHAR * szKeep;
|
|
|
|
|
szKeep = new TCHAR[ iLen + 1 ];
|
|
|
|
|
ToTchar( szKeep, a, iLen );
|
|
|
|
|
szKeep[ iLen ] = TEXT( '\0' );
|
|
|
|
|
playlist->PushBack( szKeep );
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
// If we added a second file the current index = -1 so we have to change that back
|
|
|
|
|
playlist->SetCurIndex( 0 );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Player_Play(char * FileName)
|
|
|
|
|
{
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Print("Play file <%s>\n", FileName);
|
2009-01-03 01:38:44 +00:00
|
|
|
|
|
|
|
|
|
// Check if the file exists
|
|
|
|
|
if(GetFileAttributes(FileName) == INVALID_FILE_ATTRIBUTES)
|
|
|
|
|
{
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Print("Warning: The file <%s> does not exist. Something is wrong.\n", FileName);
|
2009-01-03 01:38:44 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Playback::Stop();
|
2009-01-17 14:28:09 +00:00
|
|
|
|
//Console::Print("Stop\n");
|
2009-01-03 01:38:44 +00:00
|
|
|
|
playlist->RemoveAll();
|
2009-01-17 14:28:09 +00:00
|
|
|
|
//Console::Print("RemoveAll\n");
|
2009-01-03 01:38:44 +00:00
|
|
|
|
AddFileToPlaylist(FileName);
|
2009-01-17 14:28:09 +00:00
|
|
|
|
//Console::Print("addfiletoplaylist\n");
|
2009-01-03 01:38:44 +00:00
|
|
|
|
|
|
|
|
|
// Play the file
|
|
|
|
|
Playback::Play();
|
|
|
|
|
|
|
|
|
|
CurrentlyPlayingFile = FileName;
|
|
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
// Set volume. This must probably be done after the dll is loaded.
|
|
|
|
|
//Output_SetVolume( Playback::Volume::Get() );
|
2009-01-17 14:28:09 +00:00
|
|
|
|
//Console::Print("Volume(%i)\n", Playback::Volume::Get());
|
2009-01-03 01:38:44 +00:00
|
|
|
|
// ---------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
GlobalPause = false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 04:08:18 +00:00
|
|
|
|
void Player_Stop()
|
|
|
|
|
{
|
|
|
|
|
Playback::Stop();
|
2009-01-17 14:28:09 +00:00
|
|
|
|
//Console::Print("Stop\n");
|
2009-01-05 04:08:18 +00:00
|
|
|
|
playlist->RemoveAll();
|
|
|
|
|
|
|
|
|
|
CurrentlyPlayingFile = "";
|
|
|
|
|
|
|
|
|
|
GlobalPause = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2009-01-03 01:38:44 +00:00
|
|
|
|
void Player_Pause()
|
|
|
|
|
{
|
|
|
|
|
if (!GlobalPause)
|
|
|
|
|
{
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Print("DLL > Pause\n");
|
2009-01-03 01:38:44 +00:00
|
|
|
|
Playback::Pause();
|
|
|
|
|
GlobalPause = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Print("DLL > UnPause from Pause\n");
|
2009-01-03 01:38:44 +00:00
|
|
|
|
Player_Unpause();
|
|
|
|
|
GlobalPause = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Player_Unpause()
|
|
|
|
|
{
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Print("DLL > UnPause\n");
|
2009-01-03 01:38:44 +00:00
|
|
|
|
Playback::Play();
|
|
|
|
|
GlobalPause = false;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-05 07:02:24 +00:00
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Declarations and definitions
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/* About the volume: The colume is normally update for the output plugin in Output.cpp and for the
|
|
|
|
|
inout plugin (why?) in Playback.cpp with Playback::Volume::Set(). But I don't know how that works
|
|
|
|
|
so I only use GlobalVolume to keep track of the volume */
|
|
|
|
|
// ------------------------------
|
|
|
|
|
void Player_Mute(int Vol)
|
2009-01-03 01:38:44 +00:00
|
|
|
|
{
|
2009-01-05 07:02:24 +00:00
|
|
|
|
if(GlobalVolume == -1) GlobalVolume = Vol;
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Print("DLL > Mute <%i> <%i>\n", GlobalVolume, GlobalMute);
|
2009-01-03 01:38:44 +00:00
|
|
|
|
|
2009-01-05 07:02:24 +00:00
|
|
|
|
GlobalMute = !GlobalMute;
|
|
|
|
|
|
|
|
|
|
// Set volume
|
|
|
|
|
if(GlobalMute)
|
2009-01-03 01:38:44 +00:00
|
|
|
|
{
|
|
|
|
|
Output_SetVolume( 0 );
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Print("DLL > Volume <%i>\n", GlobalMute);
|
2009-01-03 01:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Output_SetVolume( GlobalVolume );
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Print("DLL > Volume <%i>\n", GlobalMute);
|
2009-01-03 01:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
2009-01-17 14:28:09 +00:00
|
|
|
|
//Console::Print("Volume(%i)\n", Playback::Volume::Get());
|
2009-01-03 01:38:44 +00:00
|
|
|
|
}
|
2009-01-05 07:02:24 +00:00
|
|
|
|
///////////////////////////////////////
|
2009-01-03 01:38:44 +00:00
|
|
|
|
|
|
|
|
|
|
2009-01-05 07:02:24 +00:00
|
|
|
|
void Player_Volume(int Vol)
|
2009-01-03 01:38:44 +00:00
|
|
|
|
{
|
2009-01-05 07:02:24 +00:00
|
|
|
|
GlobalVolume = Vol;
|
2009-01-03 01:38:44 +00:00
|
|
|
|
Output_SetVolume( GlobalVolume );
|
2009-01-17 14:28:09 +00:00
|
|
|
|
//Console::Print("DLL > Volume <%i> <%i>\n", GlobalVolume, GlobalCurrentVolume);
|
2009-01-03 01:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ShowConsole()
|
|
|
|
|
{
|
2009-01-17 14:28:09 +00:00
|
|
|
|
Console::Open(100, 2000, "MusicMod", true); // give room for 2000 rows
|
2009-01-03 01:38:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Player_Console(bool Console)
|
|
|
|
|
{
|
|
|
|
|
if(Console)
|
|
|
|
|
ShowConsole();
|
|
|
|
|
else
|
|
|
|
|
#if defined (_WIN32)
|
|
|
|
|
FreeConsole();
|
|
|
|
|
#endif
|
2009-01-17 14:28:09 +00:00
|
|
|
|
}
|