PrevUpHomeNext

Haiku c++ BFileGameSound play audio - 2024-11-06-01


BFileGameSound play audio

Haiku c++ BFileGameSound audio. Dig Haiku

class BFileGameSound

BFileGameSound is a c++ class of haiku api that can load, decode and play an audio file.

method .StartPlaying(), .StopPlaying()

Start playing the sound. Stop playing the sound.

method .IsPlaying()

Judge if the playing is not stopped.

method .SetPaused, .IsPaused

pause

c++ code

#include <FileGameSound.h>
#include <iostream>
#include <thread>

int main()
{
	BFileGameSound snd{"audio.wav", false};
	snd.StartPlaying();
	while (true)
	{
		std::this_thread::sleep_for(std::chrono::milliseconds(300));
		std::cout << "Oh! ... " << std::flush;
		if (! snd.IsPlaying())
		{
			std::cout << "\n\nPlaying is finished." << std::endl;
			break;
		}
	}
}

Compile & Run:

~> g++ app.cpp -std=c++23 -o app -lgame
~> ./app
Oh! ... Oh! ... Oh! ... Oh! ...
Oh! ...

Playing is finished.

Links

Haiku API Docs https://api.haiku-os.org

Haiku Home - Haiku OS

Back Index - Dig Haiku OS c++

cpp/c++

c++ std::exception:

std::cout.write(err.data(), err.size());

std::cout << std::endl;

caught:

  ===================================
  #  The c++ programming language.  #
  #                                 #
  #  Join c++ Discord: yZcauUAUyC   #
  #  Deck                           #
  ===================================

Home: cppfx.xyz

K


PrevUpHomeNext