SFML - Simple and Fast Multimedia Library

SFML 3.0.1

- Main Page
- Topics
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Loading...
Searching...
No Matches
Functions
sf::PlaybackDevice Namespace Reference

## Functions
std::vector< std::string > | getAvailableDevices ()
| Get a list of the names of all available audio playback devices.
std::optional< std::string > | getDefaultDevice ()
| Get the name of the default audio playback device.
bool | setDevice (const std::string &name)
| Set the audio playback device.
std::optional< std::string > | getDevice ()
| Get the name of the current audio playback device.

## Function Documentation

## ◆ getAvailableDevices()

std::vector< std::string > sf::PlaybackDevice::getAvailableDevices | ( |  | ) |
| nodiscard

Get a list of the names of all available audio playback devices.

This function returns a vector of strings containing the names of all available audio playback devices.

If the operating system reports multiple devices with the same name, a number will be appended to the name of all subsequent devices to distinguish them from each other. This guarantees that every entry returned by this function will represent a unique device.

For example, if the operating system reports multiple devices with the name "Sound Card", the entries returned would be:

- Sound Card
- Sound Card 2
- Sound Card 3
- ...

The default device, if one is marked as such, will be placed at the beginning of the vector.

If no devices are available, this function will return an empty vector.

Returns
  A vector of strings containing the device names or an empty vector if no devices are available

## ◆ getDefaultDevice()

std::optional< std::string > sf::PlaybackDevice::getDefaultDevice | ( |  | ) |
| nodiscard

Get the name of the default audio playback device.

This function returns the name of the default audio playback device. If none is available, an empty string is returned.

Returns
  The name of the default audio playback device

## ◆ getDevice()

std::optional< std::string > sf::PlaybackDevice::getDevice | ( |  | ) |
| nodiscard

Get the name of the current audio playback device.

Returns
  The name of the current audio playback device or `std::nullopt` if there is none

## ◆ setDevice()

bool sf::PlaybackDevice::setDevice | ( | const std::string & | name | ) |
| nodiscard

Set the audio playback device.

This function sets the audio playback device to the device with the given `name`. It can be called on the fly (i.e: while sounds are playing).

If there are sounds playing when the audio playback device is switched, the sounds will continue playing uninterrupted on the new audio playback device.

Parameters

  name | The name of the audio playback device

Returns
  `true`, if it was able to set the requested device

See also
  `getAvailableDevices`, `getDefaultDevice`