mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 06:07:11 +09:00
Expose track from MusicController
This commit is contained in:
@ -31,6 +31,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
@ -560,9 +561,9 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
BeatmapDetails.Refresh();
|
||||
|
||||
if (music != null)
|
||||
if (music?.CurrentTrack != null)
|
||||
{
|
||||
music.Looping = true;
|
||||
music.CurrentTrack.Looping = true;
|
||||
music.ResetTrackAdjustments();
|
||||
}
|
||||
|
||||
@ -588,8 +589,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
BeatmapOptions.Hide();
|
||||
|
||||
if (music != null)
|
||||
music.Looping = false;
|
||||
if (music?.CurrentTrack != null)
|
||||
music.CurrentTrack.Looping = false;
|
||||
|
||||
this.ScaleTo(1.1f, 250, Easing.InSine);
|
||||
|
||||
@ -610,8 +611,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
FilterControl.Deactivate();
|
||||
|
||||
if (music != null)
|
||||
music.Looping = false;
|
||||
if (music?.CurrentTrack != null)
|
||||
music.CurrentTrack.Looping = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -652,18 +653,30 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
BeatmapDetails.Beatmap = beatmap;
|
||||
|
||||
if (music != null)
|
||||
music.Looping = false;
|
||||
if (music?.CurrentTrack != null)
|
||||
music.CurrentTrack.Looping = false;
|
||||
}
|
||||
|
||||
private readonly WeakReference<ITrack> lastTrack = new WeakReference<ITrack>(null);
|
||||
|
||||
/// <summary>
|
||||
/// Ensures some music is playing for the current track.
|
||||
/// Will resume playback from a manual user pause if the track has changed.
|
||||
/// </summary>
|
||||
private void ensurePlayingSelected()
|
||||
{
|
||||
music.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||
music.EnsurePlayingSomething();
|
||||
ITrack track = music?.CurrentTrack;
|
||||
if (track == null)
|
||||
return;
|
||||
|
||||
bool isNewTrack = !lastTrack.TryGetTarget(out var last) || last != track;
|
||||
|
||||
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
|
||||
|
||||
if (!track.IsRunning && (music?.IsUserPaused != true || isNewTrack))
|
||||
music?.Play(true);
|
||||
|
||||
lastTrack.SetTarget(track);
|
||||
}
|
||||
|
||||
private void carouselBeatmapsLoaded()
|
||||
|
Reference in New Issue
Block a user