JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SoundFile Class Reference

Sound loaded from an OGG file. More...

#include <jngl/SoundFile.hpp>

Public Member Functions

 SoundFile (const std::string &filename, std::launch policy=std::launch::async)
 Load an OGG file called filename. More...
 
 SoundFile (const SoundFile &)=delete
 
SoundFileoperator= (const SoundFile &)=delete
 
 SoundFile (SoundFile &&) noexcept
 
SoundFileoperator= (SoundFile &&) noexcept
 
void play ()
 Play the sound once. If called twice the sound would also play twice.
 
void play (Channel &)
 
void stop ()
 Stop the last started sound.
 
void stop (Channel &)
 
bool isPlaying ()
 Whether the sound is still playing at least once.
 
void loop ()
 Play the sound in a loop. Can also be stopped using stop()
 
void loop (Channel &)
 
void setVolume (float v)
 Set volume in [0, ∞]. Default is 1.0f.
 
void load ()
 Block until the sound file has been fully decompressed and loaded. More...
 

Detailed Description

Sound loaded from an OGG file.

JNGL keeps a list of loaded sound files, so there's no need for you to use this class directly - you can just use jngl::play.

Definition at line 29 of file SoundFile.hpp.

Constructor & Destructor Documentation

◆ SoundFile()

SoundFile ( const std::string filename,
std::launch  policy = std::launch::async 
)
explicit

Load an OGG file called filename.

Loading can either happen on its own thread (std::launch::async) or the first time you try to play the file (std::launch::deferred).

Note
If the file doesn't exist this will not throw, but calling SoundFile::play, SoundFile::loop or SoundFile::load will.

Member Function Documentation

◆ load()

void load ( )

Block until the sound file has been fully decompressed and loaded.

Exceptions
std::runtime_errorFile not found or decoding errors

The documentation for this class was generated from the following file: