mirror of
https://github.com/nzp-team/dquakeplus.git
synced 2024-11-10 06:31:40 +00:00
Add .MP3 Streaming from string, play music on Main Menu
This commit is contained in:
parent
7e164cdc6c
commit
b90f7d55ea
3 changed files with 44 additions and 6 deletions
|
@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
int CDAudio_Init(void);
|
||||
void CDAudio_Play(byte track, qboolean looping);
|
||||
void CDAudio_PlayFromString(char* track_name, qboolean looping);
|
||||
void CDAudio_Stop(void);
|
||||
void CDAudio_Pause(void);
|
||||
void CDAudio_Resume(void);
|
||||
|
|
|
@ -439,6 +439,7 @@ void M_Start_Key (int key)
|
|||
{
|
||||
case K_ESCAPE:
|
||||
S_LocalSound ("sounds/menu/enter.wav");
|
||||
Cbuf_AddText("cd playstring tensioned_by_the_damned 1\n");
|
||||
Cbuf_AddText("togglemenu\n");
|
||||
break;
|
||||
}
|
||||
|
@ -1032,6 +1033,7 @@ void M_Map_Key (int key)
|
|||
if (sv.active)
|
||||
Cbuf_AddText ("disconnect\n");
|
||||
Cbuf_AddText ("maxplayers 1\n");
|
||||
Cbuf_AddText ("cd stop\n");
|
||||
Cbuf_AddText (va("map %s\n", custom_maps[m_map_cursor + multiplier].map_name));
|
||||
loadingScreen = 1;
|
||||
loadname2 = custom_maps[m_map_cursor + multiplier].map_name;
|
||||
|
@ -1180,6 +1182,7 @@ void M_SinglePlayer_Key (int key)
|
|||
if (sv.active)
|
||||
Cbuf_AddText ("disconnect\n");
|
||||
Cbuf_AddText ("maxplayers 1\n");
|
||||
Cbuf_AddText ("cd stop\n");
|
||||
Cbuf_AddText ("map ndu\n");
|
||||
loadingScreen = 1;
|
||||
loadname2 = "ndu";
|
||||
|
@ -1190,6 +1193,7 @@ void M_SinglePlayer_Key (int key)
|
|||
if (sv.active)
|
||||
Cbuf_AddText ("disconnect\n");
|
||||
Cbuf_AddText ("maxplayers 1\n");
|
||||
Cbuf_AddText ("cd stop\n");
|
||||
Cbuf_AddText ("map warehouse\n");
|
||||
loadingScreen = 1;
|
||||
loadname2 = "warehouse";
|
||||
|
@ -1200,6 +1204,7 @@ void M_SinglePlayer_Key (int key)
|
|||
if (sv.active)
|
||||
Cbuf_AddText ("disconnect\n");
|
||||
Cbuf_AddText ("maxplayers 1\n");
|
||||
Cbuf_AddText ("cd stop\n");
|
||||
Cbuf_AddText ("map christmas_special\n");
|
||||
loadingScreen = 1;
|
||||
loadname2 = "christmas_special";
|
||||
|
|
|
@ -53,6 +53,8 @@ namespace quake
|
|||
static bool paused = false;
|
||||
static bool enabled = false;
|
||||
static float cdvolume = 0;
|
||||
static int cd_loop = 0;
|
||||
static char* last_track_string = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,6 +114,13 @@ static void CD_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "playstring") == 0)
|
||||
{
|
||||
char* track_name = Cmd_Argv(2);
|
||||
qboolean loop = (qboolean)atoi(Cmd_Argv(3));
|
||||
CDAudio_PlayFromString(track_name, loop);
|
||||
}
|
||||
|
||||
if (Q_strcasecmp(command, "loop") == 0)
|
||||
{
|
||||
CDAudio_Play((byte)atoi(Cmd_Argv (2)), (qboolean) true);
|
||||
|
@ -149,6 +158,7 @@ static void CD_f (void)
|
|||
Con_Printf("Based On sceMp3 Lib\n");
|
||||
Con_Printf("Additional fixed by\n");
|
||||
Con_Printf("dr_mabuse1981 and Baker.\n");
|
||||
Con_Printf("string support: motolegacy.\n");
|
||||
Con_Printf("\n");
|
||||
return;
|
||||
}
|
||||
|
@ -178,6 +188,28 @@ void CDAudio_Track(char* trackname)
|
|||
Sys_Error(path);
|
||||
}
|
||||
|
||||
void CDAudio_PlayFromString(char* track_name, qboolean looping)
|
||||
{
|
||||
CDAudio_Stop();
|
||||
|
||||
char path[256];
|
||||
sprintf(path, "%s/tracks/%s.mp3", com_gamedir, track_name);
|
||||
|
||||
int ret = mp3_start_play(path, 0);
|
||||
cd_loop = looping;
|
||||
last_track_string = track_name;
|
||||
|
||||
if (ret != 2) playing = true;
|
||||
else {
|
||||
Con_Printf("Couldn't find %s\n", path);
|
||||
playing = false;
|
||||
Cvar_Set("bgmtype","none");
|
||||
CDAudio_VolumeChange(0);
|
||||
}
|
||||
|
||||
CDAudio_VolumeChange(0.75);
|
||||
}
|
||||
|
||||
void CDAudio_Play(byte track, qboolean looping)
|
||||
{
|
||||
/*last_track = track;
|
||||
|
@ -239,12 +271,12 @@ void CDAudio_Update(void)
|
|||
//if(changeMp3Volume) CDAudio_VolumeChange(bgmvolume.value);
|
||||
|
||||
if (strcmpi(bgmtype.string,"cd") == 0) {
|
||||
if (playing == false) {
|
||||
CDAudio_Play(last_track, (qboolean) false);
|
||||
}
|
||||
if (paused == true) {
|
||||
CDAudio_Resume();
|
||||
}
|
||||
/*if(mp3_status == MP3_END)
|
||||
{
|
||||
if(cd_loop == 1) {
|
||||
CDAudio_PlayFromString(last_track_string, qtrue);
|
||||
}
|
||||
}*/
|
||||
|
||||
} else {
|
||||
if (paused == false) {
|
||||
|
|
Loading…
Reference in a new issue