#ifndef GLOBAL_DECL
#include "global.h" // Global data types and variables
#endif
#ifndef PLAYER_DECL
#include "player.h"
#endif
player::player() // Constructor
{
is_playing = 0;
is_paused = 0;
intStopPressed = 0;
fileCmd1 = NULL;
}
int player::display_song(int intScrollPos)
{
if (update == 1)
send_text(strCurrent, 2, intScrollPos);
update = 0;
return(0);
}
int player::stop(void)
{
fputc('q', fileCmd1);
fflush(fileCmd1);
pclose(fileCmd1);
fileCmd1 = NULL;
is_playing = 0;
is_paused = 0;
update = 1;
return(0);
}
int player::pause(void)
{
fputc('5', fileCmd1);
fflush(fileCmd1);
update = 1;
return(0);
}
int player::killme(void)
{
pclose(fileCmd1);
return(0);
}
int player::play(char *strPath, char *strFname)
{
char strCmd[800];
printf("\n\nPlay request:\nPath = '%s'\nFile = '%s'\n", strPath, strFname);
strcpy(strCurrent, strFname);
strCurrent[strlen(strCurrent) - 4] = '\0';
update = 1;
strcpy(strCmd, PLAYER_PATH);
strcat(strCmd, " \"");
strcat(strCmd, strPath);
strcat(strCmd, "/");
strcat(strCmd, strFname);
strcat(strCmd, "\"");
if (is_playing == 1) // mp3 already playing - stop it..
{
fputc('q', fileCmd1);
fflush(fileCmd1);
pclose(fileCmd1);
fileCmd1 = NULL;
}
is_playing = 1;
fileCmd1 = popen(strCmd, "w"); // call the mp3 application
return(0);
}
syntax highlighted by Code2HTML, v. 0.9.1