UOperatingSystemAudioPlayer
#include <OperatingSystemSimulator/Public/Programs/MusicPlayer/OperatingSystemAudioPlayer.h>class UOperatingSystemAudioPlayerDefined in OperatingSystemAudioPlayer.h:30
Inherits:
UOperatingSystemBaseProgram
Inheritance diagram
Section titled “Inheritance diagram”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class UOperatingSystemAudioPlayer["UOperatingSystemAudioPlayer"]
class UOperatingSystemBaseProgram["UOperatingSystemBaseProgram"]
UOperatingSystemBaseProgram <|-- UOperatingSystemAudioPlayer
Collaboration diagram
Section titled “Collaboration diagram”---
config:
class:
hideEmptyMembersBox: true
---
classDiagram
class UOperatingSystemAudioPlayer["UOperatingSystemAudioPlayer"]
class UOperatingSystemBaseProgram["UOperatingSystemBaseProgram"]
UOperatingSystemAudioPlayer *-- UOperatingSystemBaseProgram
Class detail
Section titled “Class detail”---
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
Public Attributes
Section titled “Public Attributes”| Return | Name | Description |
|---|---|---|
FOnOperatingSystemAudioPlayStateChanged | OnAudioPlayStateChanged | Delegate that is triggered when the play state of the audio changes. |
FOnOperatingSystemAudioPlayerPlaybackChanged | OnAudioPlaybackChanged | Delegate that is triggered when the audio playback changes. |
FOnOperatingSystemAudioPlaybackFinished | OnAudioPlaybackFinished | Delegate that is triggered when the audio playback is finished. |
OnAudioPlayStateChanged
Section titled “OnAudioPlayStateChanged”FOnOperatingSystemAudioPlayStateChanged OnAudioPlayStateChangedDefined in OperatingSystemAudioPlayer.h:41 Delegate that is triggered when the play state of the audio changes.
Referenced by
Section titled “Referenced by”OnAudioPlaybackChanged
Section titled “OnAudioPlaybackChanged”FOnOperatingSystemAudioPlayerPlaybackChanged OnAudioPlaybackChangedDefined in OperatingSystemAudioPlayer.h:50 Delegate that is triggered when the audio playback changes.
Parameters
Section titled “Parameters”-
PlaybackTimeThe current playback time in seconds. -
PlaybackPercentThe current playback progress as a percentage (0-1).
Referenced by
Section titled “Referenced by”OnAudioPlaybackFinished
Section titled “OnAudioPlaybackFinished”FOnOperatingSystemAudioPlaybackFinished OnAudioPlaybackFinishedDefined in OperatingSystemAudioPlayer.h:54 Delegate that is triggered when the audio playback is finished.
Referenced by
Section titled “Referenced by”Public Methods
Section titled “Public Methods”| Return | Name | Description |
|---|---|---|
UOperatingSystemAudioPlayer | ||
bool | PlayAudio const | Plays the audio. Triggers ‘On Audio Play State Changed’ delegate. |
bool | StopAudio const | Stops audio playback. Triggers ‘On Audio Playback Finished’ and ‘On Audio Play State Changed’ delegates. |
bool | SetVolumeMultiplier const | Sets volume multiplier. |
bool | SetPaused const | Toggles pause state. Triggers ‘On Audio Play State Changed’ delegate. |
EAudioComponentPlayState | GetPlayState const | Returns current play state of audio component. |
float | GetAudioDuration const | Returns the duration of audio component. |
UOperatingSystemAudioPlayer
Section titled “UOperatingSystemAudioPlayer”UOperatingSystemAudioPlayer()Defined in OperatingSystemAudioPlayer.h:56
References
Section titled “References”bAllowResizingDefaultDoNotSaveGetSettingsIconObjectIdentifierSaveMethodSpaceRequiredInMBStartWindowState
PlayAudio
Section titled “PlayAudio”const
bool PlayAudio(constfloat StartTime = 0.f) constDefined in OperatingSystemAudioPlayer.h:65 Plays the audio. Triggers ‘On Audio Play State Changed’ delegate.
Parameters
Section titled “Parameters”StartTimeOptional time to start playback from.
Returns
Section titled “Returns”True if playback was started. False otherwise.
References
Section titled “References”StopAudio
Section titled “StopAudio”const
bool StopAudio() constDefined in OperatingSystemAudioPlayer.h:73 Stops audio playback. Triggers ‘On Audio Playback Finished’ and ‘On Audio Play State Changed’ delegates.
Returns
Section titled “Returns”True if audio was stopped. False otherwise.
Referenced by
Section titled “Referenced by”References
Section titled “References”SetVolumeMultiplier
Section titled “SetVolumeMultiplier”const
bool SetVolumeMultiplier(constfloat NewMultiplier) constDefined in OperatingSystemAudioPlayer.h:82 Sets volume multiplier.
Parameters
Section titled “Parameters”NewMultiplierVolume Multiplier (0-1 range).
Returns
Section titled “Returns”True if volume multiplier was set. False otherwise.
References
Section titled “References”SetPaused
Section titled “SetPaused”const
bool SetPaused(constbool bPause) constDefined in OperatingSystemAudioPlayer.h:91 Toggles pause state. Triggers ‘On Audio Play State Changed’ delegate.
Parameters
Section titled “Parameters”bPauseTrue to pause audio. False to unpause.
Returns
Section titled “Returns”True if the pause state was changed. False otherwise.
References
Section titled “References”GetPlayState
Section titled “GetPlayState”const
EAudioComponentPlayState GetPlayState() constDefined in OperatingSystemAudioPlayer.h:99 Returns current play state of audio component.
Returns
Section titled “Returns”Current state of the audio component.
References
Section titled “References”GetAudioDuration
Section titled “GetAudioDuration”const
float GetAudioDuration() constDefined in OperatingSystemAudioPlayer.h:107 Returns the duration of audio component.
Returns
Section titled “Returns”Duration of audio.
References
Section titled “References”Protected Methods
Section titled “Protected Methods”| Return | Name | Description |
|---|---|---|
void | OnOpenFile virtual override | Handles the event of opening a file in the audio player. |
void | OnClose virtual override | Handles the event of closing the audio player. |
OnOpenFile
Section titled “OnOpenFile”virtual override
virtual void OnOpenFile(UOperatingSystemFile * TargetFile, FGenericError & OutError) overrideDefined 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.
Parameters
Section titled “Parameters”-
TargetFileThe file to be opened. -
OutError(out) The error message, if any.
See also: UOperatingSystemFile
See also: FGenericError
References
Section titled “References”CurrentAudioComponentGetOperatingSystemGetProgramNameGetSettingsInternal_OnAudioFinishedInternal_OnAudioPlaybackChangedInternal_OnAudioPlayStateChangedMAKE_ERROROnAudioPlayStateChangedOP_BIND
Reimplements
Section titled “Reimplements”OnClose
Section titled “OnClose”virtual override
virtual void OnClose(FGenericError & OutError) overrideDefined 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.
Parameters
Section titled “Parameters”OutError(out) The error message, if any.
See also: FGenericError
References
Section titled “References”Reimplements
Section titled “Reimplements”Private Attributes
Section titled “Private Attributes”| Return | Name | Description |
|---|---|---|
TObjectPtr< UAudioComponent > | CurrentAudioComponent |
CurrentAudioComponent
Section titled “CurrentAudioComponent”TObjectPtr< UAudioComponent > CurrentAudioComponentDefined in OperatingSystemAudioPlayer.h:35
Referenced by
Section titled “Referenced by”Private Methods
Section titled “Private Methods”| Return | Name | Description |
|---|---|---|
void | Internal_OnAudioPlayStateChanged | Handles the event of audio play state change. |
void | Internal_OnAudioPlaybackChanged | Handles the event of audio playback change. |
void | Internal_OnAudioFinished | Handles the event of audio playback finished. |
Internal_OnAudioPlayStateChanged
Section titled “Internal_OnAudioPlayStateChanged”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.
Parameters
Section titled “Parameters”NewStateThe new play state of the audio component.
See also: EAudioComponentPlayState
See also: OnAudioPlayStateChanged
Referenced by
Section titled “Referenced by”References
Section titled “References”Internal_OnAudioPlaybackChanged
Section titled “Internal_OnAudioPlaybackChanged”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.
Parameters
Section titled “Parameters”-
PlayingSoundWaveThe USoundWave being played. -
PlaybackPercentThe current playback progress as a percentage (0-1).
See also: OnAudioPlaybackChanged
Referenced by
Section titled “Referenced by”References
Section titled “References”Internal_OnAudioFinished
Section titled “Internal_OnAudioFinished”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