/// <inheritdoc /> /// <summary> /// </summary> public Jukebox() { TrackListQueue = new List <Map>(); // If a track is already playing, add it to the queue. if (MapManager.Selected != null && MapManager.Selected.Value != null) { TrackListQueue.Add(MapManager.Selected.Value); TrackListQueuePosition++; ChangeDiscordPresenceToSongTitle(); } Size = new ScalableVector2(614, 40); Tint = Color.Black; Alpha = 0.55f; CreateTitleBackground(); CreateNowPlayingText(); CreateSongTitleContainer(); CreateSongTimeProgressBar(); // IMPORTANT! Add the contained drawable afterwards, so that it appears on top of the progress bar. SongTitleContainer.AddContainedDrawable(SongTitleText); CreateControlButtons(); AddBorder(Color.White, 2); // Make sure the audio is playing and add a fade effect. if (AudioEngine.Track != null && AudioEngine.Track.IsPaused) { AudioEngine.Track.Play(); AudioEngine.Track.Fade(ConfigManager.VolumeMusic.Value, 300); } }
/// <inheritdoc /> /// <summary> /// </summary> public Jukebox(bool ignoreRichPresence = false) { IgnoreRichPresence = ignoreRichPresence; TrackListQueue = new List <Map>(); // If a track is already playing, add it to the queue. if (MapManager.Selected != null && MapManager.Selected.Value != null) { TrackListQueue.Add(MapManager.Selected.Value); TrackListQueuePosition++; ChangeDiscordPresenceToSongTitle(); } Size = new ScalableVector2(614, 40); Image = UserInterface.JukeboxPanel; CreateTitleBackground(); CreateNowPlayingText(); CreateSongTitleContainer(); CreateSongTimeProgressBar(); // IMPORTANT! Add the contained drawable afterwards, so that it appears on top of the progress bar. SongTitleContainer.AddContainedDrawable(SongTitleText); CreateControlButtons(); // Make sure the audio is playing and add a fade effect. if (AudioEngine.Track != null && AudioEngine.Track.IsPaused) { AudioEngine.Track.Play(); AudioEngine.Track.Fade(100, 300); } }
/// <summary> /// Creates the jukebox progress bar. /// </summary> private void CreateSongTimeProgressBar() { SongTimeProgressBar = new ProgressBar(new Vector2(SongTitleContainer.Width, SongTitleContainer.Height - 4), 0, AudioEngine.Track != null && !AudioEngine.Track.IsDisposed ? AudioEngine.Track.Length : int.MaxValue, 0, Color.Transparent, Colors.MainAccent) { Alignment = Alignment.MidLeft, ActiveBar = { Alpha = 0.45f } }; // Create the invisible bar to seek through the audio. var seekBar = new ImageButton(UserInterface.BlankBox, (o, e) => { if (AudioEngine.Track == null || AudioEngine.Track.IsDisposed) { return; } // The percentage of how far the mouse is inside of the progress bar. try { var percentage = (MouseManager.CurrentState.X - SongTimeProgressBar.AbsolutePosition.X) / SongTimeProgressBar.AbsoluteSize.X; Logger.Debug($"Jukebox track seeked to: {(int)(percentage * AudioEngine.Track.Length)}ms ({(int)(percentage * 100)}%)", LogType.Runtime); lock (AudioEngine.Track) AudioEngine.Track.Seek(percentage * AudioEngine.Track.Length); } catch (Exception ex) { Logger.Error(ex, LogType.Runtime); } }) { Parent = SongTimeProgressBar, Size = SongTimeProgressBar.Size, Position = SongTimeProgressBar.Position, Alignment = SongTimeProgressBar.Alignment, Alpha = 0 }; SongTitleContainer.AddContainedDrawable(SongTimeProgressBar); }