音楽(mp3, ogg 等)の再生
#include <iostream>
#include <vector>
#include <cstdio>
using namespace hrk;
using namespace std;
namespace
{
void print_usage(const char* program_name)
{
cout << "usage: " << program_name << " <file1> <file1> ..." << endl;
}
}
int main(int argc, char *argv[])
{
const char* program_name = argv[0];
if (argc < 2) {
print_usage(program_name);
return 1;
}
vector<string> play_files;
for (int i = 1; i < argc; ++i) {
play_files.push_back(argv[i]);
}
for (vector<string>::const_iterator it = play_files.begin();
it != play_files.end(); ++it) {
cerr <<
"Music::register_alias: " << music.
what() << endl;
return 1;
}
}
cout <<
"current volume: " << music.
volume_percent() <<
" [%]" << endl;
const double fade_in = 1.0;
const double fade_out = 1.0;
for (vector<string>::const_iterator it = play_files.begin();
it != play_files.end(); ++it) {
cout << "play: " << *it << endl;
music.
play(*it, fade_in, fade_out);
getchar();
}
for (vector<string>::const_iterator it = play_files.begin();
it != play_files.end(); ++it) {
}
return 1;
}