From 1c86cfca45351b172e42d508cb55788c644ed392 Mon Sep 17 00:00:00 2001 From: whiteshark0 Date: Tue, 17 Nov 2009 18:50:57 +0000 Subject: fixed #89: wrong mp3 playback when selecting song while scrolling the issue was caused by the delayed song loading to prevent noise when scrolling git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1947 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/screens/UScreenSong.pas | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/screens/UScreenSong.pas b/src/screens/UScreenSong.pas index 9a534c51..ff2ab201 100644 --- a/src/screens/UScreenSong.pas +++ b/src/screens/UScreenSong.pas @@ -57,6 +57,9 @@ type private Equalizer: Tms_Equalizer; + PreviewOpened: Integer; // interaction of the Song that is loaded for preview music + // -1 if nothing is opened + procedure StartMusicPreview(); procedure StopMusicPreview(); public @@ -834,6 +837,8 @@ begin Equalizer := Tms_Equalizer.Create(AudioPlayback, Theme.Song.Equalizer); + PreviewOpened := -1; + if (Length(CatSongs.Song) > 0) then Interaction := 0; end; @@ -1440,7 +1445,9 @@ begin begin //Load Music only when Song Preview is activated if ( Ini.PreviewVolume <> 0 ) then - StartMusicPreview(); + StartMusicPreview() + else + PreviewOpened := -1; SetScroll; end; @@ -1473,13 +1480,13 @@ end; procedure TScreenSong.OnHide; begin + // if preview is not loaded: load musicfile now + if (PreviewOpened <> Interaction) then + AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); + // turn music volume to 100% AudioPlayback.SetVolume(1.0); - // if preview is deactivated: load musicfile now - if (IPreviewVolumeVals[Ini.PreviewVolume] = 0) then - AudioPlayback.Open(CatSongs.Song[Interaction].Path.Append(CatSongs.Song[Interaction].Mp3)); - // if hide then stop music (for party mode popup on exit) if (Display.NextScreen <> @ScreenSing) and (Display.NextScreen <> @ScreenSingModi) then @@ -1659,6 +1666,8 @@ begin if AudioPlayback.Open(Song.Path.Append(Song.Mp3)) then begin + PreviewOpened := Interaction; + AudioPlayback.Position := AudioPlayback.Length / 4; // set preview volume if (Ini.PreviewFading = 0) then @@ -1706,6 +1715,7 @@ end; procedure TScreenSong.ChangeMusic; begin StopMusicPreview(); + PreviewOpened := -1; // Preview song if activated and current selection is not a category cover if (CatSongs.VisibleSongs > 0) and -- cgit v1.2.3