/// <summary> /// 当歌曲播放完毕时是循环播放时 /// </summary> private static void OnLoopPlayback() { LogicDatas logicDatas = ModelManager.Instance.GetLogicDatas; logicDatas.CurrentSongIndex++; logicDatas.CurrentSongIndex %= logicDatas.SongsName.Length; logicDatas.Index = 0; SongControl.ReleaseAudioRelatedResources(); SongControl.LoadNextSong(logicDatas.SongsName[logicDatas.CurrentSongIndex]); }
/// <summary> /// 改变歌曲 /// </summary> /// <param name="index">歌曲索引</param> internal static void ChangeSong(int index) { if (ModelManager.Instance.GetLogicDatas.GameState == GameState.Loading) { return; } SongControl.StopSong(); SongControl.ReleaseAudioRelatedResources(); string[] songName = ModelManager.Instance.GetLogicDatas.SongsName; if (index < 0 || index >= songName.Length) { return; } ModelManager.Instance.GetLogicDatas.CurrentSongIndex = index; SongControl.LoadNextSong(songName[index]); }
/// <summary> /// 播放下一首 /// </summary> internal static void PlayNextSong() { LogicDatas logicDatas = ModelManager.Instance.GetLogicDatas; if (logicDatas.GameState == GameState.StandBy) { SongControl.LoadNextSong(logicDatas.SongsName[0]); } else if (logicDatas.GameState == GameState.Playing || logicDatas.GameState == GameState.Pause) { logicDatas.CurrentSongIndex++; logicDatas.CurrentSongIndex %= logicDatas.SongsName.Length; logicDatas.Index = 0; SongControl.StopSong(); SongControl.ReleaseAudioRelatedResources(); SongControl.LoadNextSong(logicDatas.SongsName[logicDatas.CurrentSongIndex]); } }
/// <summary> /// 当歌曲播放完毕时是顺序播放时 /// </summary> private static void OnPlayInOrder() { LogicDatas logicDatas = ModelManager.Instance.GetLogicDatas; ScenesDatas scenesDatas = ModelManager.Instance.GetScenesDatas; logicDatas.CurrentSongIndex++; logicDatas.Index = 0; if (logicDatas.CurrentSongIndex >= logicDatas.SongsName.Length) { scenesDatas.AudioSource.Stop(); UILyricControl.ResetLyric(scenesDatas.LyricItems); if (scenesDatas.VideoPlayer.isPlaying) { scenesDatas.VideoPlayer.Stop(); } logicDatas.CurrentSongIndex = logicDatas.SongsName.Length - 1; } else { SongControl.ReleaseAudioRelatedResources(); SongControl.LoadNextSong(logicDatas.SongsName[logicDatas.CurrentSongIndex]); } }
/// <summary> /// 当歌曲播放完毕时是随机播放时 /// </summary> private static void OnRandomPlay() { LogicDatas logicDatas = ModelManager.Instance.GetLogicDatas; ScenesDatas scenesDatas = ModelManager.Instance.GetScenesDatas; int index = UnityEngine.Random.Range(0, logicDatas.SongsName.Length); logicDatas.Index = 0; if (index == logicDatas.CurrentSongIndex) { scenesDatas.AudioSource.Play(); if (string.IsNullOrEmpty(scenesDatas.VideoPlayer.url) && scenesDatas.VideoPlayer.isPrepared) { scenesDatas.VideoPlayer.Play(); } UILyricControl.InitLyric(scenesDatas.LyricItems, logicDatas.LyricInfo); } else { logicDatas.CurrentSongIndex = index; SongControl.ReleaseAudioRelatedResources(); SongControl.LoadNextSong(logicDatas.SongsName[logicDatas.CurrentSongIndex]); } }