Class MusicBank
The persistent storage for playlists and music players.
Inheritance
Namespace: Stem
Assembly: Stem.dll
Syntax
public class MusicBank : ScriptableObject, IBank, ISerializationCallbackReceiver
Properties
| Improve this Doc View SourcePlayers
The collection of music players.
Declaration
public ReadOnlyCollection<MusicPlayer> Players { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<MusicPlayer> | A reference to a read-only collection of music players. |
PlaylistBatchImportMode
The batch import mode defining how new playlists will be created after the drag-drop event.
Declaration
public AudioClipImportMode PlaylistBatchImportMode { get; set; }
Property Value
Type | Description |
---|---|
AudioClipImportMode | An enum value. |
PlaylistManagementMode
The default audio clip management mode for all playlists of the music bank.
Declaration
public AudioClipManagementMode PlaylistManagementMode { get; set; }
Property Value
Type | Description |
---|---|
AudioClipManagementMode | An enum value. |
Remarks
By default, all playlists will use this value for audio clip management, however, it can be overridden by the OverrideAudioClipManagement flag.
Playlists
The collection of playlists.
Declaration
public ReadOnlyCollection<Playlist> Playlists { get; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ReadOnlyCollection<Playlist> | A reference to a read-only collection of playlists. |
PlaylistUnloadInterval
The default audio clip unload interval for all playlists of the the music bank.
Declaration
public float PlaylistUnloadInterval { get; set; }
Property Value
Type | Description |
---|---|
System.Single | A time interval in seconds. |
Remarks
By default, all playlists will use this value for audio clip unload interval, however, it can be overridden by the OverrideAudioClipManagement flag.
ShowPlayers
The flag indicating whether the music bank inspector should show the 'Players' group.
Declaration
public bool ShowPlayers { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if the 'Players' group is shown. False otherwise. |
Remarks
This property is used only by the music bank inspector and does nothing during runtime.
ShowPlaylists
The flag indicating whether the music bank inspector should show the 'Playlists' group.
Declaration
public bool ShowPlaylists { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True, if the 'Playlists' group is shown. False otherwise. |
Remarks
This property is used only by the music bank inspector and does nothing during runtime.
Methods
| Improve this Doc View SourceAddMusicPlayer(String)
Adds a new music player to the music bank.
Declaration
public MusicPlayer AddMusicPlayer(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the music player. |
Returns
Type | Description |
---|---|
MusicPlayer | A reference to a newly created music player. |
AddPlaylist(String)
Adds an empty playlist to the music bank.
Declaration
public Playlist AddPlaylist(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the playlist. |
Returns
Type | Description |
---|---|
Playlist | A reference to a newly created playlist. |
AddPlaylist(String, AudioClip)
Adds a new playlist with a single track to the music bank.
Declaration
public Playlist AddPlaylist(string name, AudioClip clip)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the playlist. |
AudioClip | clip | A reference to the audio clip with music data. |
Returns
Type | Description |
---|---|
Playlist | A reference to a newly created playlist. |
AddPlaylist(String, AudioClip[])
Adds a new playlist with multiple tracks to the music bank.
Declaration
public Playlist AddPlaylist(string name, AudioClip[] clips)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the playlist. |
AudioClip[] | clips | An array of audio clips with music data. |
Returns
Type | Description |
---|---|
Playlist | A reference to a newly created playlist. |
GetBankID()
Returns music bank ID.
Declaration
public ID GetBankID()
Returns
Type | Description |
---|---|
ID | An ID value. |
GetMusicPlayer(ID)
Searches for the specified music player by ID.
Declaration
public MusicPlayer GetMusicPlayer(ID id)
Parameters
Type | Name | Description |
---|---|---|
ID | id | ID that refers to a music player. |
Returns
Type | Description |
---|---|
MusicPlayer | A reference to a music player, if found. Null reference otherwise. |
GetMusicPlayer(String)
Searches for the specified music player with a matching name.
Declaration
public MusicPlayer GetMusicPlayer(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the music player. |
Returns
Type | Description |
---|---|
MusicPlayer | A reference to a music player, if found. Null reference otherwise. |
GetMusicPlayerID(Int32)
Gets an ID to the specific music player.
Declaration
public ID GetMusicPlayerID(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Zero-based index of the music player in the current music bank. |
Returns
Type | Description |
---|---|
ID | An ID to the specific music player. |
GetPlaylist(ID)
Searches for the specified playlist by ID.
Declaration
public Playlist GetPlaylist(ID id)
Parameters
Type | Name | Description |
---|---|---|
ID | id | ID that refers to a playlist. |
Returns
Type | Description |
---|---|
Playlist | A reference to a playlist, if found. Null reference otherwise. |
GetPlaylist(String)
Searches for the specified playlist with a matching name.
Declaration
public Playlist GetPlaylist(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the playlist. |
Returns
Type | Description |
---|---|
Playlist | A reference to a playlist, if found. Null reference otherwise. |
GetPlaylistID(Int32)
Gets an ID to the specific playlist.
Declaration
public ID GetPlaylistID(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Zero-based index of the playlist in the current music bank. |
Returns
Type | Description |
---|---|
ID | An ID to the specific playlist. |
OnAfterDeserialize()
Prepares music bank for runtime use after deserialization.
Declaration
public void OnAfterDeserialize()
Remarks
This method is automatically called by Unity during deserialization process. Don't call it manually.
OnBeforeSerialize()
Prepares music bank for serialization.
Declaration
public void OnBeforeSerialize()
Remarks
This method is automatically called by Unity during serialization process. Don't call it manually.
RegenerateBankID()
Generates a new unique ID for the music bank.
Declaration
public void RegenerateBankID()
Remarks
This method is automatically called by Stem during serialization process. Don't call it manually as it may break existing ID references.
RemoveMusicPlayer(MusicPlayer)
Removes existing music player from the music bank.
Declaration
public void RemoveMusicPlayer(MusicPlayer player)
Parameters
Type | Name | Description |
---|---|---|
MusicPlayer | player | A reference to a music player. |
Remarks
This method does nothing if the music player was not found in the music bank.
RemovePlaylist(Playlist)
Removes existing playlist from the music bank.
Declaration
public void RemovePlaylist(Playlist playlist)
Parameters
Type | Name | Description |
---|---|---|
Playlist | playlist | A reference to a playlist. |
Remarks
This method does nothing if the playlist was not found in the music bank.
All existing music players containing removed playlist will set their playlist reference to null.
Events
| Improve this Doc View SourceOnMusicPlayerAdded
The delegate informing about adding music players.
Declaration
public event MusicPlayerAddedDelegate OnMusicPlayerAdded
Event Type
Type | Description |
---|---|
MusicPlayerAddedDelegate |
OnMusicPlayerRemoved
The delegate informing about removing music players.
Declaration
public event MusicPlayerRemovedDelegate OnMusicPlayerRemoved
Event Type
Type | Description |
---|---|
MusicPlayerRemovedDelegate |
OnMusicPlayerRenamed
The delegate informing about the change of music player names.
Declaration
public event MusicPlayerRenamedDelegate OnMusicPlayerRenamed
Event Type
Type | Description |
---|---|
MusicPlayerRenamedDelegate |
OnPlaylistAdded
The delegate informing about adding playlists.
Declaration
public event PlaylistAddedDelegate OnPlaylistAdded
Event Type
Type | Description |
---|---|
PlaylistAddedDelegate |
OnPlaylistRemoved
The delegate informing about removing playlists.
Declaration
public event PlaylistRemovedDelegate OnPlaylistRemoved
Event Type
Type | Description |
---|---|
PlaylistRemovedDelegate |
OnPlaylistRenamed
The delegate informing about the change of playlist names.
Declaration
public event PlaylistRenamedDelegate OnPlaylistRenamed
Event Type
Type | Description |
---|---|
PlaylistRenamedDelegate |