playmus.c
changeset 13 1e489d8b97d8
parent 10 2fbd0414a1fc
child 23 0578063e33d8
     1.1 --- a/playmus.c	Sun Oct 31 14:16:07 1999 +0000
     1.2 +++ b/playmus.c	Mon Nov 01 00:40:43 1999 +0000
     1.3 @@ -56,15 +56,38 @@
     1.4  
     1.5  void Usage(char *argv0)
     1.6  {
     1.7 -	fprintf(stderr, "Usage: %s |-l] [-8] [-r rate] [-s] <musicfile>\n", argv0);
     1.8 +	fprintf(stderr, "Usage: %s [-i] |-l] [-8] [-r rate] [-s] <musicfile>\n", argv0);
     1.9  }
    1.10 -	
    1.11 +
    1.12 +void Menu(void)
    1.13 +{
    1.14 +	char buf[10];
    1.15 +
    1.16 +	printf("Available commands: (p)ause (r)esume (h)alt > ");
    1.17 +	fflush(stdin);
    1.18 +	scanf("%s",buf);
    1.19 +	switch(buf[0]){
    1.20 +	case 'p': case 'P':
    1.21 +		Mix_PauseMusic();
    1.22 +		break;
    1.23 +	case 'r': case 'R':
    1.24 +		Mix_ResumeMusic();
    1.25 +		break;
    1.26 +	case 'h': case 'H':
    1.27 +		Mix_HaltMusic();
    1.28 +		break;
    1.29 +	}
    1.30 +	printf("Music playing: %s Paused: %s\n", Mix_PlayingMusic() ? "yes" : "no", 
    1.31 +		   Mix_PausedMusic() ? "yes" : "no");
    1.32 +}
    1.33 +
    1.34  main(int argc, char *argv[])
    1.35  {
    1.36  	Uint32 audio_rate;
    1.37  	Uint16 audio_format;
    1.38  	int audio_channels;
    1.39  	int looping = 0;
    1.40 +	int interactive = 0;
    1.41  	int i;
    1.42  
    1.43  	/* Initialize variables */
    1.44 @@ -84,6 +107,9 @@
    1.45  		if ( strcmp(argv[i], "-l") == 0 ) {
    1.46  			looping = -1;
    1.47  		} else
    1.48 +		if ( strcmp(argv[i], "-i") == 0 ) {
    1.49 +			interactive = 1;
    1.50 +		} else
    1.51  		if ( strcmp(argv[i], "-8") == 0 ) {
    1.52  			audio_format = AUDIO_U8;
    1.53  		} else {
    1.54 @@ -130,8 +156,11 @@
    1.55  
    1.56  	/* Play and then exit */
    1.57  	Mix_FadeInMusic(music,looping,2000);
    1.58 -	while ( Mix_PlayingMusic() ) {
    1.59 -		SDL_Delay(100);
    1.60 +	while ( Mix_PlayingMusic() || Mix_PausedMusic() ) {
    1.61 +		if(interactive)
    1.62 +			Menu();
    1.63 +		else
    1.64 +			SDL_Delay(100);
    1.65  	}
    1.66  	exit(0);
    1.67  }