logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityMusicPlayerServiceFactory

    Factory for creating Unity music player service instances with complete setup and configuration.
    Handles the creation of GameObject hierarchies, audio emitter setup, and service initialization for music playback.
    Manages dependency injection and ensures proper integration between audio systems and music track management.
    Converts music track definitions to runtime entities and configures the service for immediate use.

    Inheritance
    object
    UnityMusicPlayerServiceFactory
    Implements
    IMusicPlayerServiceFactory
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.MusicPlayer.Infrastructure.Services
    Assembly: Serenity.UnityMusicPlayer.Infrastructure.dll
    Syntax
    public class UnityMusicPlayerServiceFactory : IMusicPlayerServiceFactory

    Constructors

    UnityMusicPlayerServiceFactory(UnityAudioPlayerEmitterFactory, IEventDispatcherService, IGameSettingsService, ILogService)

    Initializes a new instance of UnityMusicPlayerServiceFactory with required dependencies.
    Sets up all necessary services and factories for creating music player service instances.
    Establishes the dependency injection chain for proper service configuration.

    Declaration
    public UnityMusicPlayerServiceFactory(UnityAudioPlayerEmitterFactory audioPlayerEmitterFactory, IEventDispatcherService eventDispatcherService, IGameSettingsService gameSettingsService, ILogService logService)
    Parameters
    Type Name Description
    UnityAudioPlayerEmitterFactory audioPlayerEmitterFactory

    Factory for creating audio emitter components.

    IEventDispatcherService eventDispatcherService

    Service for event handling and dispatching.

    IGameSettingsService gameSettingsService

    Service for game settings management.

    ILogService logService

    Service for logging and error reporting.

    Methods

    CreateAudioEmitters(string, IAudioPlayerSettings)

    Creates the GameObject hierarchy and audio emitter components for the music player service.
    Generates individual audio emitter objects based on the configured channel count in the audio player settings.
    Organizes audio emitters under a parent GameObject for proper scene hierarchy management.
    Returns the parent GameObject containing all configured audio emitters.

    Declaration
    protected GameObject CreateAudioEmitters(string serviceName, IAudioPlayerSettings audioPlayerSettings)
    Parameters
    Type Name Description
    string serviceName

    Name for the service to be used in GameObject naming.

    IAudioPlayerSettings audioPlayerSettings

    Settings containing channel count and audio configuration.

    Returns
    Type Description
    GameObject

    GameObject containing all created audio emitter components.

    CreateService(string, IAudioPlayerSettings, IMusicTrackDefinition[], ILogService)

    Creates a complete music player service instance with audio emitters and music track configuration.
    Builds the GameObject hierarchy, initializes the service component, and loads music tracks.
    Handles dependency injection and ensures the service is ready for immediate music playback operations.
    Returns a fully configured IMusicPlayerService ready for integration into the application.

    Declaration
    public IMusicPlayerService CreateService(string serviceName, IAudioPlayerSettings settings, IMusicTrackDefinition[] musicTracksSettings, ILogService logService)
    Parameters
    Type Name Description
    string serviceName

    Unique name for the music player service instance.

    IAudioPlayerSettings settings

    Audio player settings for configuration and setup.

    IMusicTrackDefinition[] musicTracksSettings

    Array of music track definitions to load into the service.

    ILogService logService

    Log service instance for error reporting and debugging.

    Returns
    Type Description
    IMusicPlayerService

    Fully configured IMusicPlayerService instance ready for use.

    Implements

    IMusicPlayerServiceFactory
    In this article
    © 2026 Serenity. All Rights Reserved