logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Interface IMusicPlayerService

    Interface representing a music player service.

    Namespace: Serenity.MusicPlayer.Application.Interfaces
    Assembly: Serenity.MusicPlayer.Application.dll
    Syntax
    public interface IMusicPlayerService : IService, IFoundationSettings

    Properties

    IsEnabled

    Gets or sets a value indicating whether the music player is enabled.

    Declaration
    bool IsEnabled { get; set; }
    Property Value
    Type Description
    bool

    True if the music player is enabled; otherwise, false.

    Methods

    AddMusicTrack(MusicTrack)

    Adds a music track for playback.

    Declaration
    void AddMusicTrack(MusicTrack musicTrack)
    Parameters
    Type Name Description
    MusicTrack musicTrack

    The music track to add.

    Enable()

    Enables the music player service.

    Declaration
    void Enable()

    Initialize(IGameSettingsService, IAudioPlayerSettings, object, IEventDispatcherService, ILogService)

    Initializes the music player service.

    Declaration
    void Initialize(IGameSettingsService gameSettingsService, IAudioPlayerSettings settings, object audioSourceList, IEventDispatcherService eventDispatcherService, ILogService logService)
    Parameters
    Type Name Description
    IGameSettingsService gameSettingsService

    The game settings service.

    IAudioPlayerSettings settings

    The audio player settings.

    object audioSourceList

    The list of audio sources.

    IEventDispatcherService eventDispatcherService

    The event dispatcher service.

    ILogService logService

    The log service.

    Remarks

    This method must be called before using the music player service.

    PauseSong()

    Pauses the currently playing song.

    Declaration
    void PauseSong()

    PlayNextSong()

    Plays the next song in the playlist.

    Declaration
    void PlayNextSong()

    PlayPreviousSong()

    Plays the previous song in the playlist.

    Declaration
    void PlayPreviousSong()

    PlaySong(MusicPlayerTransitionType, float)

    Plays the currently selected song. Existing audio is transitioned out according to transitionType.

    Declaration
    void PlaySong(MusicPlayerTransitionType transitionType = 0, float transitionDuration = 0.5)
    Parameters
    Type Name Description
    MusicPlayerTransitionType transitionType

    Transition strategy applied when moving from the current track to the new one. Defaults to CUT.

    float transitionDuration

    Duration of the transition in seconds. Ignored for CUT.

    PlaySongById(string, bool, MusicPlayerTransitionType, float)

    Plays a specific song resolved by its track id. Existing audio is transitioned out according to transitionType.

    Declaration
    void PlaySongById(string musicTrackId, bool loop, MusicPlayerTransitionType transitionType = 0, float transitionDuration = 0.5)
    Parameters
    Type Name Description
    string musicTrackId

    The id of the music track to play.

    bool loop

    When true the track restarts at the end; when false playback stops at the end.

    MusicPlayerTransitionType transitionType

    Transition strategy applied when moving from the current track to the new one. Defaults to CUT.

    float transitionDuration

    Duration of the transition in seconds. Ignored for CUT.

    ResumeSong()

    Resumes the currently paused song.

    Declaration
    void ResumeSong()

    SetMusicTracks(List<MusicTrack>)

    Sets the music tracks for playback.

    Declaration
    void SetMusicTracks(List<MusicTrack> musicTracks)
    Parameters
    Type Name Description
    List<MusicTrack> musicTracks

    The list of music tracks to set.

    StopSong()

    Stops the currently playing song.

    Declaration
    void StopSong()
    In this article
    © 2026 Serenity. All Rights Reserved