Added XMMS-CTL interaction
This commit is contained in:
parent
a57e1052a0
commit
759b6d161e
2 changed files with 143 additions and 1 deletions
|
@ -1643,7 +1643,7 @@ loadedfile_t *COM_LoadFile (char *path, int usehunk)
|
|||
{
|
||||
int h;
|
||||
byte *buf;
|
||||
char base[32];
|
||||
char base[MAX_OSPATH];
|
||||
int len;
|
||||
// 2001-09-12 Returning information about loaded file by Maddes start
|
||||
int bufsize;
|
||||
|
|
142
tracker/tracker_xmms-ctl.c
Normal file
142
tracker/tracker_xmms-ctl.c
Normal file
|
@ -0,0 +1,142 @@
|
|||
/*
|
||||
Copyright (C) 2015 Marco "eukara" Hladik
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "globaldef.h"
|
||||
|
||||
static int xmms_loop = 1;
|
||||
static int xmms_track;
|
||||
|
||||
static qboolean xmms_playing = false;
|
||||
static qboolean xmms_wasplaying = false;
|
||||
|
||||
void Tracker_Play(byte track, qboolean looping)
|
||||
{
|
||||
char buffer [32];
|
||||
sprintf(buffer, "xmms-ctl -track-set %i", (int) track);
|
||||
system(buffer);
|
||||
system("xmms-ctl -play");
|
||||
|
||||
xmms_loop = looping == true ? 0 : 1;
|
||||
xmms_track = (int) track;
|
||||
xmms_playing = true;
|
||||
|
||||
Con_Printf("XMMS: Now playing song %i\n", xmms_track);
|
||||
}
|
||||
|
||||
void Tracker_Stop(void)
|
||||
{
|
||||
system("xmms-ctl -stop");
|
||||
xmms_wasplaying = false;
|
||||
xmms_playing = false;
|
||||
|
||||
Con_Printf("XMMS: Track %i stopped\n", xmms_track);
|
||||
}
|
||||
|
||||
|
||||
void Tracker_Pause(void)
|
||||
{
|
||||
system("xmms-ctl -pause");
|
||||
xmms_wasplaying = xmms_playing;
|
||||
xmms_playing = false;
|
||||
|
||||
Con_Printf("XMMS: Track %i paused\n", xmms_track);
|
||||
}
|
||||
|
||||
|
||||
void Tracker_Resume(void)
|
||||
{
|
||||
if (!xmms_wasplaying)
|
||||
return;
|
||||
system("xmms-ctl -play");
|
||||
xmms_playing = false;
|
||||
|
||||
Con_Printf("XMMS: Resuming track %i\n", xmms_track);
|
||||
}
|
||||
|
||||
// DO NOTHING
|
||||
void Tracker_Update(void)
|
||||
{
|
||||
#if 0
|
||||
char buffer [32];
|
||||
|
||||
if(xmms_loop)
|
||||
{
|
||||
int xmms_trackl = system("xmms-ctl -track-get");
|
||||
if(xmms_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);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void XMMS_f (void)
|
||||
{
|
||||
char *command;
|
||||
int i;
|
||||
|
||||
if (Cmd_Argc() < 2)
|
||||
return;
|
||||
|
||||
command = Cmd_Argv (1);
|
||||
|
||||
if (Q_strcasecmp(command, "play") == 0)
|
||||
{
|
||||
Tracker_Play((byte)Q_atoi(Cmd_Argv (2)), false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "stop") == 0)
|
||||
{
|
||||
Tracker_Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "pause") == 0)
|
||||
{
|
||||
Tracker_Pause();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "resume") == 0)
|
||||
{
|
||||
Tracker_Resume();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "quit") == 0)
|
||||
{
|
||||
system("xmms-ctl -quit");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
int Tracker_Init(void)
|
||||
{
|
||||
Cmd_AddCommand ("xmms", XMMS_f); // link DUMB
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
void Tracker_Shutdown(void)
|
||||
{
|
||||
}
|
Loading…
Reference in a new issue