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(" 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(" 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::h: system_sounds::hand().play(); break;
case console_key::q: system_sounds::question().play(); break;
default: break;
}
}
}
};
}
startup_(system_sound_example::program::main);
// This code can produce the following output :
//
static console_key_info read_key()
Obtains the next character or function key pressed by the user. The pressed key is displayed in the c...
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static void exit()
Terminates this process and returns an exit code to the operating system.
static system_sound exclamation()
Gets the sound associated with the Exclamation program event in the current Windows sound scheme.
static system_sound beep()
Gets the sound associated with the Beep program event in the current Windows sound scheme.
static system_sound hand()
Gets the sound associated with the Hand program event in the current Windows sound scheme.
static system_sound question()
Gets the sound associated with the Question program event in the current Windows sound scheme.
static system_sound asterisk()
Gets the sound associated with the Asterisk program event in the current Windows sound scheme.
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:167
@ a
The A key.
Definition console_key.hpp:88
@ h
The H key.
Definition console_key.hpp:102
@ q
The Q key.
Definition console_key.hpp:120
@ b
The B key.
Definition console_key.hpp:90
@ escape
The ESC (ESCAPE) key.
Definition console_key.hpp:34
@ e
The E key.
Definition console_key.hpp:96
The xtd::media namespace contains classes for playing sound files and accessing sounds provided by th...
Definition system_sound.hpp:12
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8