Search Results for

    Show / Hide Table of Contents

    Class AudioPlayerManager

    Handles managing BackgroundAudio.Players, including generating and auto-removing unused players. Generally used like a , where BackgroundAudio is mapped to a list of BackgroundAudio.Players.

    Inheritance
    Object
    AudioPlayerManager
    Namespace: OmiyaGames.Audio
    Assembly: cs.temp.dll.dll
    Syntax
    public class AudioPlayerManager : MonoBehaviour
    Remarks

    The MIT License (MIT)

    Copyright (c) 2022 Omiya Games

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

    RevisionDescription
    Version: 1.0.0
    Date: 5/22/2022
    Author: Taro Omiya
    Initial verison.

    Properties

    GarbageCollectAfterSeconds

    Gets or sets how long an idle (basically, stopped) BackgroundAudio.Player remains in memory before being auto-deleted by this manager.

    Declaration
    public float GarbageCollectAfterSeconds { get; set; }
    Property Value
    Type Description
    Single

    Methods

    CreateManager(Transform, String)

    Creates a new , and attaching an instance of AudioPlayerManager.

    Declaration
    public static AudioPlayerManager CreateManager(Transform parent, string gameObjectName)
    Parameters
    Type Name Description
    Transform parent

    The this manager will be added as a child to. Can be null

    String gameObjectName

    The name of the new that's created by this method.

    Returns
    Type Description
    AudioPlayerManager

    A new instance of AudioPlayerManager, attached by a new , which is a child of parent.

    CreatePlayerCoroutine(AssetRef<BackgroundAudio>, Action<BackgroundAudio.Player>)

    Starts a coroutine that generates a new BackgroundAudio.Player from audio.

    Declaration
    public IEnumerator CreatePlayerCoroutine(AssetRef<BackgroundAudio> audio, Action<BackgroundAudio.Player> onPlayerCreated = null)
    Parameters
    Type Name Description
    AssetRef<BackgroundAudio> audio

    The audio file that generates players.

    Action<BackgroundAudio.Player> onPlayerCreated

    Delegate that triggers at the end of this coroutine. Argument will be set to the newly generated BackgroundAudio.Player.

    Returns
    Type Description
    IEnumerator

    A coroutine that creates a new BackgroundAudio.Player.

    Exceptions
    Type Condition
    ArgumentNullException

    If audio's state is Null.

    GarbageCollect(AudioPlayerManager.AudioState)

    Destroys any BackgroundAudio.Players that has the same state as destroyPlayersWithStates.

    Declaration
    public void GarbageCollect(AudioPlayerManager.AudioState destroyPlayersWithStates = AudioPlayerManager.AudioState.Stopped)
    Parameters
    Type Name Description
    AudioPlayerManager.AudioState destroyPlayersWithStates

    The state of BackgroundAudio.Players to destroy.

    GetPlayer(AssetRef<BackgroundAudio>, AudioPlayerManager.AudioState)

    Gets the first BackgroundAudio.Player associated with an audio asset at a specific state.

    Declaration
    public BackgroundAudio.Player GetPlayer(AssetRef<BackgroundAudio> audio, AudioPlayerManager.AudioState playerState = AudioPlayerManager.AudioState.All)
    Parameters
    Type Name Description
    AssetRef<BackgroundAudio> audio

    The audio file that generates players.

    AudioPlayerManager.AudioState playerState

    Filters BackgroundAudio.Players based on state.

    Returns
    Type Description
    BackgroundAudio.Player

    The first BackgroundAudio.Player that plays the audio clips from audio that is in the same state as playerState. Returns null if none is found.

    Exceptions
    Type Condition
    ArgumentNullException

    If audio's state is Null.

    See Also
    GetPlayers(AssetRef<BackgroundAudio>, AudioPlayerManager.AudioState)
    GetPlayers(AssetRef<BackgroundAudio>, AudioPlayerManager.AudioState, in List<BackgroundAudio.Player>)

    GetPlayers(AssetRef<BackgroundAudio>, AudioPlayerManager.AudioState)

    Gets a list of players associated with audio, filtered by playerState. This method creates a new .

    Declaration
    public List<BackgroundAudio.Player> GetPlayers(AssetRef<BackgroundAudio> audio, AudioPlayerManager.AudioState playerState = AudioPlayerManager.AudioState.All)
    Parameters
    Type Name Description
    AssetRef<BackgroundAudio> audio

    The audio file that generates players.

    AudioPlayerManager.AudioState playerState

    Filters BackgroundAudio.Players based on state.

    Returns
    Type Description
    List<BackgroundAudio.Player>

    List of BackgroundAudio.Players associated with audio, and has the same state as playerState.

    Exceptions
    Type Condition
    ArgumentNullException

    If audio's state is Null.

    See Also
    GetPlayers(AssetRef<BackgroundAudio>, AudioPlayerManager.AudioState, in List<BackgroundAudio.Player>)

    GetPlayers(AssetRef<BackgroundAudio>, AudioPlayerManager.AudioState, in List<BackgroundAudio.Player>)

    Gets a list of players associated with audio, filtered by playerState. This method recycles a .

    Declaration
    public void GetPlayers(AssetRef<BackgroundAudio> audio, AudioPlayerManager.AudioState playerState, in List<BackgroundAudio.Player> returnPlayers)
    Parameters
    Type Name Description
    AssetRef<BackgroundAudio> audio

    The audio file that generates players.

    AudioPlayerManager.AudioState playerState

    Filters BackgroundAudio.Players based on state.

    List<BackgroundAudio.Player> returnPlayers

    The list to append BackgroundAudio.Players to. Effectively the return variable.

    Exceptions
    Type Condition
    ArgumentNullException

    If audio's state is Null.

    IsPlayerMatchingState(BackgroundAudio.Player, AudioPlayerManager.AudioState)

    Checks if an BackgroundAudio.Player is at a state that matches any of the flags in state.

    Declaration
    public static bool IsPlayerMatchingState(BackgroundAudio.Player player, AudioPlayerManager.AudioState state)
    Parameters
    Type Name Description
    BackgroundAudio.Player player

    The player to check the state.

    AudioPlayerManager.AudioState state

    Flags to compare the state of the player.

    Returns
    Type Description
    Boolean

    true if the is in a state that matches any one of flags in state.

    Exceptions
    Type Condition
    ArgumentNullException

    If player is null.

    In This Article
    Back to top Copyright © 2022 Omiya Games