diff --git a/Sources/Linaris/AlbumPage.xaml b/Sources/Linaris/AlbumPage.xaml index 360ae6f..8c19412 100644 --- a/Sources/Linaris/AlbumPage.xaml +++ b/Sources/Linaris/AlbumPage.xaml @@ -57,7 +57,7 @@ - + diff --git a/Sources/Linaris/AlbumPage.xaml.cs b/Sources/Linaris/AlbumPage.xaml.cs index b50dd43..66b931f 100644 --- a/Sources/Linaris/AlbumPage.xaml.cs +++ b/Sources/Linaris/AlbumPage.xaml.cs @@ -1,3 +1,4 @@ +using CommunityToolkit.Maui.Views; using Model; namespace Linaris; @@ -20,7 +21,8 @@ public partial class AlbumPage : ContentPage InitializeComponent(); album = (Application.Current as App).Manager.CurrentAlbum; BindingContext = album; - } + + } private async void GoToInfoTitle(object sender, EventArgs e) { @@ -30,4 +32,15 @@ public partial class AlbumPage : ContentPage await Navigation.PushAsync(new InfoTitlePage()); } } + + protected override void OnDisappearing() + { + base.OnDisappearing(); + ContentView footer = this.FindByName("Footer"); + var musicElement = footer?.FindByName("music"); + if (musicElement != null) + { + musicElement.Stop(); + } + } } \ No newline at end of file diff --git a/Sources/Linaris/FooterPage.xaml b/Sources/Linaris/FooterPage.xaml index 316c6ba..38bd297 100644 --- a/Sources/Linaris/FooterPage.xaml +++ b/Sources/Linaris/FooterPage.xaml @@ -2,15 +2,16 @@ - + - - + + diff --git a/Sources/Linaris/FooterPage.xaml.cs b/Sources/Linaris/FooterPage.xaml.cs index 17ca4a5..49d2407 100644 --- a/Sources/Linaris/FooterPage.xaml.cs +++ b/Sources/Linaris/FooterPage.xaml.cs @@ -1,95 +1,58 @@ -using NAudio.Wave; -using Plugin.Maui.Audio; +using Model; +using Model.Stub; +using System.ComponentModel; +using System.Runtime.CompilerServices; namespace Linaris; -public partial class FooterPage : ContentView +public partial class FooterPage : ContentView, INotifyPropertyChanged { - public FooterPage() - { - InitializeComponent(); - BindingContext = (Application.Current as App).Manager; - } - - - public void RewindButton_Clicked(Object sender, EventArgs e) - { - /*audioFile.Position = 0; - outputDevice?.Play(); - Play.Source = "pause.png"; - Timer_Elapsed(sender, e); - timer = new System.Timers.Timer(1000); - timer.Elapsed += Timer_Elapsed; - timer.Enabled = true;*/ - } + private readonly Manager Manager = (Application.Current as App).Manager; - public void NextButton_Clicked(Object sender, EventArgs e) + public FooterPage() { - /*audioFile.Position = audioFile.Length;*/ + InitializeComponent(); + BindingContext = Manager.CurrentPlaying; } - public void StopButton_Clicked(object sender, EventArgs e) - { - /*outputDevice.Stop(); - audioFile.Position = 0;*/ - } - public void Slider_ValueChanged(object sender, ValueChangedEventArgs e) + public void RewindButton_Clicked(object sender, EventArgs e) { - /*outputDevice.Volume = (float)e.NewValue;*/ + if (Manager.CurrentPlaylist == null || Manager.CurrentPlaying == null) return; + Manager.PreviousTitle(); + Dispatcher.DispatchAsync(() => + { + music.Source = Manager.CurrentPlaying.Path; + }); } - public void Bar_ValueChanged(object sender, ValueChangedEventArgs e) + public void NextButton_Clicked(object sender, EventArgs e) { - /*if (changementManuel) + if (Manager.CurrentPlaylist == null || Manager.CurrentPlaying == null) return; + Manager.NextTitle(); + Dispatcher.DispatchAsync(() => { - double totalSeconds = audioFile.TotalTime.TotalSeconds; - double newPosition = e.NewValue * totalSeconds; - - audioFile.CurrentTime = TimeSpan.FromSeconds(newPosition); - } - else - { - changementManuel = true; - }*/ + music.Source = Manager.CurrentPlaying.Path; + }); } - private void PlaybackStoppedHandler(object sender, StoppedEventArgs e) + public void ShuffleButton_Clicked(object sender, EventArgs e) { - /*if (closing) - { - outputDevice.Dispose(); - audioFile.Dispose(); - } - else - { - Play.Dispatcher.Dispatch(() => Play.Source = "play.png"); - }*/ + Manager.Shuffle(); } - private void Timer_Elapsed(object sender, EventArgs e) + public void LoopButton_Clicked(object sender, EventArgs e) { - /*TimeSpan totalTimeSpan = audioFile.TotalTime; - TimeSpan currentTimeSpan = audioFile.CurrentTime; - - string totalTimeFormatted = totalTimeSpan.ToString(@"hh\:mm\:ss"); - string currentTimeFormatted = currentTimeSpan.ToString(@"hh\:mm\:ss"); - - changementManuel = false; - - bar.Dispatcher.Dispatch(() => bar.Value = audioFile.CurrentTime.TotalSeconds / audioFile.TotalTime.TotalSeconds); - currentTime.Dispatcher.Dispatch(() => currentTime.Text = currentTimeFormatted); - endTime.Dispatcher.Dispatch(() => endTime.Text = totalTimeFormatted);*/ - + Manager.Loop(); } - private void LoadNewAudioFile(string filePath) + public void OnCompleted(object sender, EventArgs e) { - /*if (outputDevice.PlaybackState == PlaybackState.Playing) + if (Manager.CurrentPlaying == null) return; + Manager.NextTitle(); + Dispatcher.DispatchAsync(() => { - outputDevice.Stop(); - } - audioFile = new AudioFileReader(filePath); - outputDevice.Init(audioFile);*/ + music.Source = Manager.CurrentPlaying.Path; + }); } } \ No newline at end of file diff --git a/Sources/Linaris/InfoTitlePage.xaml b/Sources/Linaris/InfoTitlePage.xaml index 88a5662..16c0d60 100644 --- a/Sources/Linaris/InfoTitlePage.xaml +++ b/Sources/Linaris/InfoTitlePage.xaml @@ -29,6 +29,6 @@ - + \ No newline at end of file diff --git a/Sources/Linaris/InfoTitlePage.xaml.cs b/Sources/Linaris/InfoTitlePage.xaml.cs index cb9d207..1eb4768 100644 --- a/Sources/Linaris/InfoTitlePage.xaml.cs +++ b/Sources/Linaris/InfoTitlePage.xaml.cs @@ -1,3 +1,4 @@ +using CommunityToolkit.Maui.Views; using Model; namespace Linaris; @@ -25,4 +26,15 @@ public partial class InfoTitlePage : ContentPage artist = (Application.Current as App).Manager.GetAlbumById(infoTitle.AlbumID).Artist; BindingContext = this; } + + protected override void OnDisappearing() + { + base.OnDisappearing(); + ContentView footer = this.FindByName("Footer"); + var musicElement = footer?.FindByName("music"); + if (musicElement != null) + { + musicElement.Stop(); + } + } } \ No newline at end of file diff --git a/Sources/Linaris/Layout.xaml b/Sources/Linaris/Layout.xaml index 855ddd1..80a927c 100644 --- a/Sources/Linaris/Layout.xaml +++ b/Sources/Linaris/Layout.xaml @@ -4,9 +4,9 @@ x:Class="Linaris.Layout"> -