private static void LogoAnimationPrefix() { if (TrackConfigManager.trackConfig == null) { return; } Dictionary <string, TrackConfig> trackList = TrackConfigManager.trackConfig.trackList; if (trackList == null || !trackList.ContainsKey(TitleScreenTrack)) { return; } TrackConfig track = trackList[TitleScreenTrack]; if (track == null || string.IsNullOrEmpty(track.filePath)) { return; } AudioClip clip = TrackLoadingUtils.LoadMusicTrackNow(track); if (clip != null && AudioHandler.audioHandler != null) { AudioHandler.audioHandler.musicTrackRealList[23] = clip; AudioHandler.audioHandler.gc.sessionDataBig.musicTrackDic[TitleScreenTrack] = clip; } }
public void ReadTestConfig() { string config = GenerateTestConfig(); TrackConfig track = new TrackConfig(config); Assert.AreEqual(1, track.TrackItems.Count); Assert.AreEqual("XPF", track.TrackItems[0].Path); Assert.AreEqual("2015.1", track.TrackItems[0].Branch); }
public void CreateTracker() { string config = GenerateTest2Config(); TrackConfig track = new TrackConfig(config); Tracker tracker = new Tracker(track.TrackItems); Assert.AreEqual(2, tracker.Branches.Count); Assert.AreEqual("2015.1", tracker.Branches[0].Name); Assert.AreEqual("2015.2", tracker.Branches[1].Name); }
private static void HandleTrackChanged(string trackName, string modDirName, TrackConfig config) { if (IsTrackNameAvailable(modDirName + "_" + trackName)) { Debug.LogWarning("detected track-change in config for mod: " + modDirName + " track: " + trackName + " but track didn't previously (mis-detected addition as change?)"); } AudioHandlerPatcher.OnCustomTrackChanged(new CustomMusicLoadSpec { trackName = trackName, modDirName = modDirName, audioType = config.audioType, filePath = config.filePath, callback = OnCustomTrackLoaded }); }
private static void HandleTrackAddition(string trackName, string modDirName, TrackConfig config) { if (!IsTrackNameAvailable(modDirName + "_" + trackName)) { Debug.LogError("unable to load track: " + trackName + " from config: " + modDirName + "! TrackName is already in use."); return; } AudioHandlerPatcher.OnCustomTrackAddition(new CustomMusicLoadSpec { trackName = trackName, modDirName = modDirName, audioType = config.audioType, filePath = config.filePath, callback = OnCustomTrackLoaded }); }
internal static (MusicLoadResult, AudioClip) AddMusic(string trackName, AudioType formatType, string filePath) { if (!IsTrackNameAvailable(trackName)) { return(MusicLoadResult.DuplicateTrackName, null); } var trackConfig = new TrackConfig { audioType = formatType, filePath = filePath }; if (!File.Exists(trackConfig.GetAbsolutePath())) { return(MusicLoadResult.FileNotFound, null); } AudioClip clip = TrackLoadingUtils.LoadMusicTrackNow(trackConfig); return(clip == null ? (MusicLoadResult.UnknownError, null) : (MusicLoadResult.Success, clip)); }
internal static IEnumerator AddMusicAsync(string trackName, AudioType formatType, string filePath, Action <MusicLoadResult, AudioClip> callback = null) { if (!IsTrackNameAvailable(trackName)) { callback?.Invoke(MusicLoadResult.DuplicateTrackName, null); yield break; } var trackConfig = new TrackConfig { audioType = formatType, filePath = filePath }; if (!File.Exists(trackConfig.GetAbsolutePath())) { callback?.Invoke(MusicLoadResult.FileNotFound, null); yield break; } yield return(TrackLoadingUtils.LoadMusicTrack(trackConfig, clip => { callback?.Invoke(clip == null ? MusicLoadResult.UnknownError : MusicLoadResult.Success, clip); })); }
internal static IEnumerator LoadMusicTrack(TrackConfig trackConfig, Action <AudioClip> callback) { AudioClip audioClip = null; string path = trackConfig.GetAbsolutePath(); if (!File.Exists(path)) { Debug.LogError("Unable to load track at path: " + path + "! File does not exist."); callback?.Invoke(null); yield break; } UnityWebRequest webRequest = trackConfig.audioType == AudioType.MPEG ? UnityWebRequest.Get(path) : UnityWebRequestMultimedia.GetAudioClip(path, trackConfig.audioType); webRequest.SendWebRequest(); while (!webRequest.isDone) { yield return(new WaitForSecondsRealtime(0.05f)); } if (webRequest.isNetworkError || webRequest.isHttpError) { Debug.LogError("Failed to load musicTrack at: " + path); } else { audioClip = trackConfig.audioType == AudioType.MPEG ? Mp3ToWavClip(Path.GetFileName(path) + ".wav", webRequest.downloadHandler.data) : DownloadHandlerAudioClip.GetContent(webRequest); webRequest.Dispose(); } callback.Invoke(audioClip); }
internal static AudioClip LoadMusicTrackNow(TrackConfig trackConfig) { AudioClip audioClip = null; string path = trackConfig.GetAbsolutePath(); if (!File.Exists(path)) { Debug.LogError("Unable to load track at path: " + path + "! File does not exist."); return(null); } UnityWebRequest webRequest = trackConfig.audioType == AudioType.MPEG ? UnityWebRequest.Get(path) : UnityWebRequestMultimedia.GetAudioClip(path, trackConfig.audioType); webRequest.SendWebRequest(); while (!webRequest.isDone) { Thread.Sleep(50); } if (webRequest.isNetworkError || webRequest.isHttpError) { Debug.LogError("Failed to load musicTrack at: " + path); } else { audioClip = trackConfig.audioType == AudioType.MPEG ? Mp3ToWavClip(Path.GetFileName(path) + ".wav", webRequest.downloadHandler.data) : DownloadHandlerAudioClip.GetContent(webRequest); webRequest.Dispose(); } return(audioClip); }
public TrackEntiy(TrackConfig config, TrackIO state) { this.TrackIO = state; this.Config = config; }
public TrackEntiy() { Config = new TrackConfig(); TrackIO = new TrackIO(); }
internal static void OnTrackChanged(string trackName, TrackConfig trackConfig) { trackChangedQueue[trackName] = trackConfig; }
internal static void OnTrackAddition(string trackName, TrackConfig trackConfig) { trackAdditionQueue[trackName] = trackConfig; }