xmms-ctl music stops now when quit, based upon a suggestion
This commit is contained in:
parent
759b6d161e
commit
89c24da057
1 changed files with 33 additions and 6 deletions
|
@ -25,6 +25,7 @@ static int xmms_track;
|
|||
|
||||
static qboolean xmms_playing = false;
|
||||
static qboolean xmms_wasplaying = false;
|
||||
static qboolean xmmsctl_initialized = false;
|
||||
|
||||
void Tracker_Play(byte track, qboolean looping)
|
||||
{
|
||||
|
@ -33,11 +34,11 @@ void Tracker_Play(byte track, qboolean looping)
|
|||
system(buffer);
|
||||
system("xmms-ctl -play");
|
||||
|
||||
xmms_loop = looping == true ? 0 : 1;
|
||||
xmms_loop = looping == true ? 1 : 0;
|
||||
xmms_track = (int) track;
|
||||
xmms_playing = true;
|
||||
|
||||
Con_Printf("XMMS: Now playing song %i\n", xmms_track);
|
||||
Con_Printf("XMMS: Now playing song %i, looping %i\n", xmms_track, xmms_loop);
|
||||
}
|
||||
|
||||
void Tracker_Stop(void)
|
||||
|
@ -74,16 +75,31 @@ void Tracker_Resume(void)
|
|||
void Tracker_Update(void)
|
||||
{
|
||||
#if 0
|
||||
char buffer [32];
|
||||
if(!xmmsctl_initialized)
|
||||
return;
|
||||
|
||||
if(xmms_loop)
|
||||
{
|
||||
int xmms_trackl = system("xmms-ctl -track-get");
|
||||
if(xmms_track != xmms_track)
|
||||
int current_track;
|
||||
FILE *fp;
|
||||
char buffer [32];
|
||||
|
||||
fp = popen("/usr/local/bin/xmms-ctl -track-get", "r");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
Con_Printf("Can't get track listing from XMMS\n" );
|
||||
return;
|
||||
}
|
||||
while (fgets(buffer, sizeof(buffer)-1, fp) != NULL) {
|
||||
current_track = atoi(buffer);
|
||||
}
|
||||
|
||||
if(current_track != xmms_track)
|
||||
{
|
||||
sprintf(buffer, "xmms-ctl -track-set %i", xmms_track);
|
||||
system(buffer);
|
||||
Con_Printf("XMMS: looping track %i, tried playing %i \n", xmms_track, xmms_trackl);
|
||||
Con_Printf("XMMS: looping track %i\n", xmms_track);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -132,6 +148,16 @@ static void XMMS_f (void)
|
|||
|
||||
int Tracker_Init(void)
|
||||
{
|
||||
FILE *fp;
|
||||
fp = popen("/usr/local/bin/xmms-ctl", "r");
|
||||
|
||||
if (fp == NULL)
|
||||
{
|
||||
Con_Printf("XMMS: Cannot find XMMS-CTL!\n" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
xmmsctl_initialized = true;
|
||||
Cmd_AddCommand ("xmms", XMMS_f); // link DUMB
|
||||
return 1;
|
||||
}
|
||||
|
@ -139,4 +165,5 @@ int Tracker_Init(void)
|
|||
|
||||
void Tracker_Shutdown(void)
|
||||
{
|
||||
Tracker_Stop(); // Because requested
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue