/// <summary> /// Event handler for the metadata of the track being changed /// </summary> /// <param name="metaData">Metadata of the track</param> void HandleMetadataChanged(MLMusicService.Metadata metaData) { metadataPreviousTrack.text = string.Format("Previous: {0}", musicService.PreviousTrackMetadata.TrackTitle); metadataNextTrack.text = string.Format("Next: {0}", musicService.NextTrackMetadata.TrackTitle); trackLengthMS = MLMusicService.TrackLength; }
/// <summary> /// Update the UI status text with the latest data. /// </summary> void Update() { statusText.text = string.Format("<color=#dbfb76><b>{0}</b></color>\n{1}: {2}\n", LocalizeManager.GetString("ControllerData"), LocalizeManager.GetString("Status"), LocalizeManager.GetString(ControllerStatus.Text)); #if PLATFORM_LUMIN MLMusicService.Metadata metaData = musicService.CurrentTrackMetadata; statusText.text += string.Format("\n<color=#dbfb76><b>{0}</b></color>\n{1}: {2}\n{3}: {4}\n{5}: {6}\n{7}: {8}\n{9}: {10}\n{11}: {12}\n{13}: {14}\n", LocalizeManager.GetString("MusicServiceData"), LocalizeManager.GetString("Status"), LocalizeManager.GetString("Ok"), LocalizeManager.GetString("TrackTitle"), metaData.TrackTitle, LocalizeManager.GetString("AlbumName"), metaData.AlbumInfoName, LocalizeManager.GetString("AlbumURL"), metaData.AlbumInfoUrl, LocalizeManager.GetString("AlbumCoverURL"), metaData.AlbumInfoCoverUrl, LocalizeManager.GetString("ArtistName"), metaData.ArtistInfoName, LocalizeManager.GetString("ArtistURL"), metaData.ArtistInfoUrl); #endif }
/// <summary> /// Handles an error from the MLMusicService. /// </summary> /// <param name="error">The error that ocurred.</param> private void HandleError(MLMusicService.Error error) { statusText.text = string.Format("<color=#dbfb76><b>{0}</b></color>\n{1}: {2}\n", LocalizeManager.GetString("ControllerData"), LocalizeManager.GetString("Status"), LocalizeManager.GetString(ControllerStatus.Text)); MLMusicService.Metadata metaData = musicService.CurrentTrackMetadata; statusText.text += string.Format("<color=#dbfb76><b>{0}</b></color>\n{1}: {2} - {3}: {4}, {5}: {6}", LocalizeManager.GetString("MusicServiceData"), LocalizeManager.GetString("Status"), LocalizeManager.GetString("Error"), LocalizeManager.GetString("Type"), error.Type, LocalizeManager.GetString("Code"), error.Code); enabled = false; return; }
/// <summary> /// Event handler for the metadata of the track being changed /// </summary> /// <param name="metaData">Metadata of the track</param> void HandleMetadataChanged(MLMusicService.Metadata metaData) { CurrentTrackMetadata = metaData; MLResult result = MLMusicService.GetMetadata(ref previousTrackMetadata, -1); if (!result.IsOk) { Debug.LogErrorFormat("MLMusicServiceBehavior failed to get the metadata of the previous track, disabling script. Reason: {0}.", result); enabled = false; return; } result = MLMusicService.GetMetadata(ref nextTrackMetadata, 1); if (!result.IsOk) { Debug.LogErrorFormat("MLMusicServiceBehavior failed to get the metadata of the next track, disabling script. Reason: {0}.", result); enabled = false; return; } OnMetadataChanged?.Invoke(metaData); }
private static void HandleMetadataChange(ref MLMusicServiceNativeBindings.MetadataNative metadata, IntPtr data) { MLMusicService.Metadata lambdaExtra = metadata.Data; MLThreadDispatch.Call(lambdaExtra, OnMetadataChange); }