Skip to content
Francisco Dias edited this page Sep 19, 2024 · 8 revisions

Music

The following functions, constants and structures allow you to use the Steam Music API.

Functions

These functions are provided for getting and setting the media player playback:

Constants

These are the constants used by this API:



Back To Top

steam_music_is_enabled

This function returns whether Steam music is enabled.


Syntax:

steam_music_is_enabled()



Returns:

Boolean


Example:

global.steam_music_enabled = steam_music_is_enabled();

The above code gets if Steam music player is enabled and stores the result in a global variable.




Back To Top

steam_music_is_playing

This function returns whether Steam music is playing.

Note

This function returns true even if a track is paused.


Syntax:

steam_music_is_playing()



Returns:

Boolean


Example:

global.steam_music_playing = steam_music_is_playing();

The above code gets if the Steam music player is playing and stores the result in a global variable.




Back To Top

steam_music_get_status

This function gets the current status of the media player as SteamMusicStatus.


Syntax:

steam_music_get_status()



Returns:

Real


Example:

if (steam_music_get_status == steam_music_playing) {
    steam_music_pause();
}

The above code gets if the Steam music player is playing. If it is, it pauses the playback.




Back To Top

steam_music_play

This function resumes playback of the current track. Returns true if successful.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.


Syntax:

steam_music_play()



Returns:

Boolean


Triggers:

Steam Async Event

Key Type Description
event_type String The string value "steam_music_playback_status_has_changed"



Back To Top

steam_music_pause

This function pauses the current track. Returns true if successful.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.


Syntax:

steam_music_pause()



Returns:

Boolean


Triggers:

Steam Async Event

Key Type Description
event_type String The string value "steam_music_playback_status_has_changed"



Back To Top

steam_music_play_next

This function plays the next track. If the current track is the last, it loops to the first one. Returns true if successful.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.


Syntax:

steam_music_play_next()



Returns:

Boolean


Triggers:

Steam Async Event

Key Type Description
event_type String The string value "playback_status_has_changed"



Back To Top

steam_music_play_previous

This function plays the previous track. It resets the current track first, and goes to the last one if called again. If the current track is the first, it DOES NOT loop to the last one. Returns true if successful.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.


Syntax:

steam_music_play_previous()



Returns:

Boolean


Triggers:

Steam Async Event

Key Type Description
event_type String The string value "steam_music_playback_status_has_changed"



Back To Top

steam_music_set_volume

This function sets the volume of Steam music player only (not the system volume). If a number higher than 1 is entered, it defaults to 1. Returns true if successful.

This function operates asynchronously, which means that it does not immediately return the requested result. Instead, upon completion of the task, it will trigger the Steam Async Event.


Syntax:

steam_music_set_volume(volume)
Argument Type Description
volume Real The volume that you want to set as a real.



Returns:

N/A


Triggers:

Steam Async Event

This callback is triggered whenever the volume is changed via the Steam client UI.

Key Type Description
event_type String The string value "steam_music_volume_has_changed"
volume Real The current volume of the music player



Back To Top

SteamMusicStatus

These constants represent the status of the music player.


Member Description
steam_music_playback_undefined 0
steam_music_playback_playing 1
steam_music_playback_paused 2
steam_music_playback_idle 3