Skip to content

Music Player

Introduction

Actor responsible for playing, pausing and stopping music. It also allows you to adjust music volume

Dependencies

The inal relies on other components of this plugin to work:

  • Logger: Used to log useful information to help you debug any issues you might experience

Components

The inal uses the following components:

Name Description Type
AudioPlayer Actor responsible for playing, pausing and stopping music. It also allows you to adjust music volume UUSKAudioComponent*

API Reference

Properties

Property Description Type Default Value
PlayOnStart Should the music automatically play when the actor is spawned? bool true

Functions

Name Description Params Return
GetAudioComponent Get a reference to the audio component UUSKAudioComponent*
A reference to the audio component
SetVolume Adjust the playback volume of the music NewVolume (float)
The new volume of the music
Play Play the music
Pause Pause the music
Stop Stop the music
FadeOut Fade out the music FadeDuration (float)
The duration of the fade
FadeIn Fade in the music FadeDuration (float)
The duration of the fade

Blueprint Usage

You can use the inal using Blueprints by adding one of the following nodes:

  • Ultimate Starter Kit > Audio > Get Audio Component
  • Ultimate Starter Kit > Audio > Set Volume
  • Ultimate Starter Kit > Audio > Play
  • Ultimate Starter Kit > Audio > Pause
  • Ultimate Starter Kit > Audio > Stop
  • Ultimate Starter Kit > Audio > Fade Out
  • Ultimate Starter Kit > Audio > Fade In

C++ Usage

Before you can use the plugin, you first need to enable the plugin in your Build.cs file:

PublicDependencyModuleNames.Add("USK");

The inal can now be used in any of your C++ files:

#include "USK/Audio/MusicPlayer.h"

void ATestActor::Test()
{
    // inal is a pointer to the final
    UUSKAudioComponent* AudioComponent = inal->GetAudioComponent();
    inal->SetVolume(NewVolume);
    inal->Play();
    inal->Pause();
    inal->Stop();
    inal->FadeOut(FadeDuration);
    inal->FadeIn(FadeDuration);
}