xtd 0.2.0
Loading...
Searching...
No Matches
system_sounds.cpp

Shows how tto use xtd::media::system_sounds and xtd::media::system_sounds classes.

#include <xtd/media/system_sounds>
#include <xtd/console>
#include <xtd/environment>
#include <xtd/startup>
using namespace xtd;
using namespace xtd::media;
namespace system_sound_example {
class program {
public:
// The main entry point for the application.
static auto main() {
console::write_line("Type corresponding key to play sound :");
console::write_line();
console::write_line(" a : asterisk");
console::write_line(" b : beep");
console::write_line(" e : exclamation");
console::write_line(" h : hand");
console::write_line(" q : question");
console::write_line();
console::write_line(" Esc : exit");
while (true) {
auto key_info = console::read_key(true);
switch (key_info.key()) {
case console_key::a: system_sounds::asterisk().play(); break;
case console_key::b: system_sounds::beep().play(); break;
case console_key::e: system_sounds::exclamation().play(); break;
case console_key::h: system_sounds::hand().play(); break;
case console_key::q: system_sounds::question().play(); break;
case console_key::escape: environment::exit(0); break;
default: break;
}
}
}
};
}
startup_(system_sound_example::program::main);
// This code can produce the following output:
//
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.h:166
The xtd::media namespace contains classes for playing sound files and accessing sounds provided by th...
Definition system_sound.h:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10