Skip to content

UOperatingSystemAudioPlayer

#include <OperatingSystemSimulator/Public/Programs/MusicPlayer/OperatingSystemAudioPlayer.h>
class UOperatingSystemAudioPlayer

Defined in OperatingSystemAudioPlayer.h:30

Inherits: UOperatingSystemBaseProgram

---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemAudioPlayer["UOperatingSystemAudioPlayer"]
  class UOperatingSystemBaseProgram["UOperatingSystemBaseProgram"]
  UOperatingSystemBaseProgram <|-- UOperatingSystemAudioPlayer
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemAudioPlayer["UOperatingSystemAudioPlayer"]
  class UOperatingSystemBaseProgram["UOperatingSystemBaseProgram"]
  UOperatingSystemAudioPlayer *-- UOperatingSystemBaseProgram
---
config:
  class:
    hideEmptyMembersBox: true
---
classDiagram
  class UOperatingSystemAudioPlayer {
    +OnAudioPlayStateChanged : FOnOperatingSystemAudioPlayStateChanged(
    +OnAudioPlaybackChanged : FOnOperatingSystemAudioPlayerPlaybackCha
    +OnAudioPlaybackFinished : FOnOperatingSystemAudioPlaybackFinished(
    +UOperatingSystemAudioPlayer()
    +PlayAudio(const float StartTime=0.f) const bool()
    +StopAudio() const bool()
    +SetVolumeMultiplier(const float NewMultiplier) const bool()
    +SetPaused(const bool bPause) const bool()
    +GetPlayState() const EAudioComponentPlayState()
    +GetAudioDuration() const float()
    +OnOpenFile(UOperatingSystemFile *TargetFile, FGenericE void()
    +OnClose(FGenericError &OutError) override void()
    +CurrentAudioComponent : TObjectPtr()< UAudioComponent() >
    +Internal_OnAudioPlayStateChanged(EAudioComponentPlayState NewState) void()
    +Internal_OnAudioPlaybackChanged(const USoundWave *PlayingSoundWave, const f void()
    +Internal_OnAudioFinished() void()
  }

The UOperatingSystemAudioPlayer class is an abstract class that represents an audio player in the operating system. It inherits from UOperatingSystemBaseProgram and provides functionality to play audio files, control playback, and retrieve information about the audio.

This class includes the following features:

  • Playing audio: The PlayAudio method starts the playback of the audio file and triggers the OnAudioPlayStateChanged delegate.

  • Stopping audio: The StopAudio method stops the playback of the audio file and triggers the OnAudioPlaybackFinished and OnAudioPlayStateChanged delegates.

  • Changing volume: The SetVolumeMultiplier method sets the volume multiplier of the audio file.

  • Pausing and unpausing: The SetPaused method toggles the pause state of the audio file and triggers the OnAudioPlayStateChanged delegate.

  • Retrieving play state: The GetPlayState method returns the current play state of the audio file.

  • Retrieving audio duration: The GetAudioDuration method returns the duration of the audio file.

See also: UOperatingSystemBaseProgram

ReturnNameDescription
FOnOperatingSystemAudioPlayStateChangedOnAudioPlayStateChangedDelegate that is triggered when the play state of the audio changes.
FOnOperatingSystemAudioPlayerPlaybackChangedOnAudioPlaybackChangedDelegate that is triggered when the audio playback changes.
FOnOperatingSystemAudioPlaybackFinishedOnAudioPlaybackFinishedDelegate that is triggered when the audio playback is finished.

FOnOperatingSystemAudioPlayStateChanged OnAudioPlayStateChanged

Defined in OperatingSystemAudioPlayer.h:41 Delegate that is triggered when the play state of the audio changes.


FOnOperatingSystemAudioPlayerPlaybackChanged OnAudioPlaybackChanged

Defined in OperatingSystemAudioPlayer.h:50 Delegate that is triggered when the audio playback changes.

  • PlaybackTime The current playback time in seconds.

  • PlaybackPercent The current playback progress as a percentage (0-1).


FOnOperatingSystemAudioPlaybackFinished OnAudioPlaybackFinished

Defined in OperatingSystemAudioPlayer.h:54 Delegate that is triggered when the audio playback is finished.

ReturnNameDescription
UOperatingSystemAudioPlayer
boolPlayAudio constPlays the audio. Triggers ‘On Audio Play State Changed’ delegate.
boolStopAudio constStops audio playback. Triggers ‘On Audio Playback Finished’ and ‘On Audio Play State Changed’ delegates.
boolSetVolumeMultiplier constSets volume multiplier.
boolSetPaused constToggles pause state. Triggers ‘On Audio Play State Changed’ delegate.
EAudioComponentPlayStateGetPlayState constReturns current play state of audio component.
floatGetAudioDuration constReturns the duration of audio component.

UOperatingSystemAudioPlayer()

Defined in OperatingSystemAudioPlayer.h:56


const

bool PlayAudio(constfloat StartTime = 0.f) const

Defined in OperatingSystemAudioPlayer.h:65 Plays the audio. Triggers ‘On Audio Play State Changed’ delegate.

  • StartTime Optional time to start playback from.

True if playback was started. False otherwise.


const

bool StopAudio() const

Defined in OperatingSystemAudioPlayer.h:73 Stops audio playback. Triggers ‘On Audio Playback Finished’ and ‘On Audio Play State Changed’ delegates.

True if audio was stopped. False otherwise.


const

bool SetVolumeMultiplier(constfloat NewMultiplier) const

Defined in OperatingSystemAudioPlayer.h:82 Sets volume multiplier.

  • NewMultiplier Volume Multiplier (0-1 range).

True if volume multiplier was set. False otherwise.


const

bool SetPaused(constbool bPause) const

Defined in OperatingSystemAudioPlayer.h:91 Toggles pause state. Triggers ‘On Audio Play State Changed’ delegate.

  • bPause True to pause audio. False to unpause.

True if the pause state was changed. False otherwise.


const

EAudioComponentPlayState GetPlayState() const

Defined in OperatingSystemAudioPlayer.h:99 Returns current play state of audio component.

Current state of the audio component.


const

float GetAudioDuration() const

Defined in OperatingSystemAudioPlayer.h:107 Returns the duration of audio component.

Duration of audio.

ReturnNameDescription
voidOnOpenFile virtual overrideHandles the event of opening a file in the audio player.
voidOnClose virtual overrideHandles the event of closing the audio player.

virtual override

virtual void OnOpenFile(UOperatingSystemFile * TargetFile, FGenericError & OutError) override

Defined in OperatingSystemAudioPlayer.h:124 Handles the event of opening a file in the audio player.

This method is called when a file is opened in the audio player. It creates the audio component and sets up the necessary delegates for playback control. If the file is not supported by the audio player, an error is generated.

  • TargetFile The file to be opened.

  • OutError (out) The error message, if any.

See also: UOperatingSystemFile

See also: FGenericError


virtual override

virtual void OnClose(FGenericError & OutError) override

Defined in OperatingSystemAudioPlayer.h:136 Handles the event of closing the audio player.

This method is called when the audio player is being closed. It stops the audio playback if it is currently playing and marks the current audio component as garbage. The current audio component is then set to nullptr.

  • OutError (out) The error message, if any.

See also: FGenericError

ReturnNameDescription
TObjectPtr< UAudioComponent >CurrentAudioComponent

TObjectPtr< UAudioComponent > CurrentAudioComponent

Defined in OperatingSystemAudioPlayer.h:35

ReturnNameDescription
voidInternal_OnAudioPlayStateChangedHandles the event of audio play state change.
voidInternal_OnAudioPlaybackChangedHandles the event of audio playback change.
voidInternal_OnAudioFinishedHandles the event of audio playback finished.

void Internal_OnAudioPlayStateChanged(EAudioComponentPlayState NewState)

Defined in OperatingSystemAudioPlayer.h:151 Handles the event of audio play state change.

This method is called when the play state of the audio changes. It triggers the OnAudioPlayStateChanged delegate.

  • NewState The new play state of the audio component.

See also: EAudioComponentPlayState

See also: OnAudioPlayStateChanged


void Internal_OnAudioPlaybackChanged(constUSoundWave * PlayingSoundWave, constfloat PlaybackPercent)

Defined in OperatingSystemAudioPlayer.h:164 Handles the event of audio playback change.

This method is called when the audio playback changes. It triggers the OnAudioPlaybackChanged delegate.

  • PlayingSoundWave The USoundWave being played.

  • PlaybackPercent The current playback progress as a percentage (0-1).

See also: OnAudioPlaybackChanged


void Internal_OnAudioFinished()

Defined in OperatingSystemAudioPlayer.h:174 Handles the event of audio playback finished.

This method is called when the audio playback is finished. It triggers the OnAudioPlaybackFinished delegate.

See also: OnAudioPlaybackFinished