rawr
public text v1 · immutable#include <audiere.h>
#include <fstream>
#include <iostream>
#include <time.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <stdio.h>
#include <windows.h>
using namespace audiere;
using namespace std;
void sleep(unsigned int mseconds);
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
char * cmdParam, int cmdShow)
{
AudioDevicePtr device(OpenDevice());
if(!device)
{
return 0;
}
vector<string> filenames;
vector<int> lastPlayed;
string line;
ifstream playlist("default.m3u");
int count=0;
if(playlist.is_open())
{
if(!playlist.eof())
{
//Dump the first line of the file
getline(playlist,line);
}
while(!playlist.eof())
{
count++;
getline(playlist,line);
getline(playlist,line);
//cout<<line<<endl;
filenames.push_back(line);
lastPlayed.push_back(0);
}
playlist.close();
}
//Seed the random generator
srand((unsigned)time(0));
int curSong;
curSong=(rand()%count);
OutputStreamPtr stream;
stream=OpenSound(device,filenames.at(curSong).c_str(),true);
stream->play();
lastPlayed.at(curSong)=time(0);
cout<<curSong+1<<":" <<filenames.at(curSong)<<endl;
char entry;
vector<int> requests;
int reqNum;
int canPlay=0;
while(true)
{
if(stream->isPlaying()==false)
{
while(canPlay==0)
{
if(!requests.empty())
{
curSong=requests.at(0);
requests.erase(requests.begin());
}
else
{
curSong=(rand()%count);
}
if(lastPlayed.at(curSong)+3600<time(0))
{
canPlay=1;
}
else
{
cout<<"This song has already been played within 1 hour: "<<curSong+1<<endl;
}
}
canPlay=0;
stream=OpenSound(device,filenames.at(curSong).c_str(),true);
stream->play();
lastPlayed.at(curSong)=time(0);
cout<<curSong+1<<":" <<filenames.at(curSong)<<endl;
}
//entry=console>Getch();
if(entry=='s')
{
stream->stop();
}
if(entry=='r')
{
cout<<"Please type a song number to request: ";
cin>>reqNum;
requests.push_back(reqNum-1);
}
}
return 0;
}
void sleep(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message,WPARAM wParam,LPARAM lParam)
{
cout<<"m00";
switch(Message)
{
case WM_KEYDOWN:
switch(wParam)
{
case VK_RETURN:
cout<<"lolar";
break;
}
break;
}
}