All pastes #274819 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-12-11 00:06 UTC
rendered paste body
#include <iostream>
#include <conio.h>
#include "audiere.h"
using namespace audiere;
using namespace std;

OutputStreamPtr changeSong(AudioDevicePtr device)
{
	char musicfilename[100];
	
	// prompt for new song to play	
	cout<<"Enter new file path"<<endl;
	cin.getline(musicfilename,100);

	cout << "Loading " << musicfilename << endl;
	OutputStreamPtr sound(OpenSound(device,musicfilename, false));
	
	return sound;
}

int main(int argc, char *argv[])
{
	cout<<"Wildinc's music player"<<endl;
	cout<<"----------------------";
	cout<<endl<<endl<<endl;
	cout<<endl<<"This Music Player is Wriiten in C++ and "<<endl;
	cout<<"uses the Aduiere API and classes.This Music  "<<endl;
	cout<<"Player is capable of playing a lot of file formats";
	cout<<endl<<"including .MP3 , .WAV ."<<endl<<endl;
	cout<<"If you have any questions of suggestions"<<endl;
	cout<<"Email me at wild@inbox.com"<<endl<<endl;
	cout<<"For help press 'h'"<<endl;
	cout<<"-----------------------------------------------------"<<endl;

	AudioDevicePtr device(OpenDevice());	
	OutputStreamPtr sound = changeSong(device);

	float volume = 0.1f;
	char input;

	// until the user presses 'q' for quit...
	while(input != 'q')
	{		
		sound->setVolume(volume);

		cout << "Playing song..." << endl;

		sound->play();
		sound->setRepeat(true);
		
		input=getch();

		if(input=='i')
		volume=volume+0.1;

		if(input=='d')
		volume=volume-0.1;

		if(input=='m')
		volume=0.0;

		if(input=='r')
		sound->reset();

		if (volume > 1.0)
		volume=1.0;

		if (volume < 0.0)
		volume=0.0;

		if(input == 'h')
		{
			cout<<"To increase volume press 'i'"<<endl;
			cout<<"To decrease volume press 'd'"<<endl;
			cout<<"To restart the song press 'r'"<<endl;
			cout<<"To change the song press 'c'"<<endl;
			cout<<"To quit press 'q'"<<endl;
		}
		
		if(input == 'c')
		{			
			sound->stop();
			sound = changeSong(device);
			float volume = 0.1f;
		}
	}

	return 0;
}