Music Player
Workflow
Functional music player app which supports essential player features, including playlists, shuffle, repeat and so on.
Music Player app depends on its manager and scriptable objects. It supports multiple playlists which you can manage using the manager component. You can add new music items using Tools > DreamOS > Select Music Library. All playlists and items will be generated at runtime.
Fetch Music Data
If you want to apply the music data to an object (such as cover art), you can add the ‘Music Player Data Item’ component to your image or TMP objects.
Scripting
using UnityEngine;
using Michsky.DreamOS; // DreamOS namespace
public class SampleClass : MonoBehaviour
{
[SerializeField] private MusicPlayerManager musicPlayer; // App variable
void YourFunction()
{
// Set playback
musicPlayer.Play();
musicPlayer.Pause();
musicPlayer.Stop();
musicPlayer.PrevTrack();
musicPlayer.NextTrack();
musicPlayer.Mute();
// Set shuffle and repeate state
musicPlayer.shuffle = true;
musicPlayer.repeat = false;
// Play custom music
musicPlayer.PlayCustomClip(AudioClip clip, Sprite cover, "Clip Name", "Author");
// Get values
int duration = musicPlayer.GetDuration();
string normalizedDuration = musicPlayer.GetNormalizedDuration();
int playTime = musicPlayer.GetPlayTime();
string normalizedPlayTime = musicPlayer.GetNormalizedPlayTime();
Sprite cover = musicPlayer.GetCoverArt();
string track = musicPlayer.GetTrackName();
string artist = musicPlayer.GetArtistName();
string album = musicPlayer.GetAlbumName();
}
}
How can we help?
A premium WordPress theme with an integrated Knowledge Base,
providing 24/7 community-based support.