diff --git a/Sources/Linaris/AlbumPage.xaml b/Sources/Linaris/AlbumPage.xaml index 74e2caa..885c584 100644 --- a/Sources/Linaris/AlbumPage.xaml +++ b/Sources/Linaris/AlbumPage.xaml @@ -11,6 +11,10 @@ + + + + + + diff --git a/Sources/Linaris/AppShell.xaml b/Sources/Linaris/AppShell.xaml index b7211ae..25406ec 100644 --- a/Sources/Linaris/AppShell.xaml +++ b/Sources/Linaris/AppShell.xaml @@ -9,7 +9,7 @@ diff --git a/Sources/Linaris/FooterPage.xaml b/Sources/Linaris/FooterPage.xaml new file mode 100644 index 0000000..8397b17 --- /dev/null +++ b/Sources/Linaris/FooterPage.xaml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/Linaris/FooterPage.xaml.cs b/Sources/Linaris/FooterPage.xaml.cs new file mode 100644 index 0000000..adaa690 --- /dev/null +++ b/Sources/Linaris/FooterPage.xaml.cs @@ -0,0 +1,126 @@ +using NAudio.Wave; + +namespace Linaris; + +public partial class FooterPage : ContentView +{ + WaveOutEvent outputDevice; + AudioFileReader audioFile; + System.Timers.Timer timer; + bool changementManuel = true; + bool closing = false; + string morceauEnCours; + + public FooterPage() + { + InitializeComponent(); + outputDevice = new WaveOutEvent(); + + // (s,a) = convention, s = sender, a = arguments, si appli fermée, on free tout + outputDevice.PlaybackStopped += PlaybackStoppedHandler; + + morceauEnCours = "D:\\Musique\\Création\\winter.mp3"; + audioFile = new AudioFileReader(morceauEnCours); + outputDevice.Init(audioFile); + } + + public void PlayButton_Clicked(object sender, EventArgs e) + { + string url = ((FileImageSource)Play.Source).File; + if (url == "play.png") + { + outputDevice?.Play(); + Play.Source = "pause.png"; + Timer_Elapsed(sender, e); + timer = new System.Timers.Timer(1000); + timer.Elapsed += Timer_Elapsed; + timer.Enabled = true; + } + else + { + outputDevice?.Pause(); + Play.Source = "play.png"; + } + } + + 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; + } + + public void NextButton_Clicked(Object sender, EventArgs e) + { + audioFile.Position = audioFile.Length; + } + + public void StopButton_Clicked(object sender, EventArgs e) + { + outputDevice.Stop(); + audioFile.Position = 0; + } + + public void Slider_ValueChanged(object sender, ValueChangedEventArgs e) + { + outputDevice.Volume = (float)e.NewValue; + } + + public void Bar_ValueChanged(object sender, ValueChangedEventArgs e) + { + if (changementManuel) + { + double totalSeconds = audioFile.TotalTime.TotalSeconds; + double newPosition = e.NewValue * totalSeconds; + + audioFile.CurrentTime = TimeSpan.FromSeconds(newPosition); + } + else + { + changementManuel = true; + } + } + + private void PlaybackStoppedHandler(object sender, StoppedEventArgs e) + { + if (closing) + { + outputDevice.Dispose(); + audioFile.Dispose(); + } + else + { + Play.Dispatcher.Dispatch(() => Play.Source = "play.png"); + } + } + + private void Timer_Elapsed(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); + + } + + private void LoadNewAudioFile(string filePath) + { + if (outputDevice.PlaybackState == PlaybackState.Playing) + { + outputDevice.Stop(); + } + audioFile = new AudioFileReader(filePath); + outputDevice.Init(audioFile); + } +} \ No newline at end of file diff --git a/Sources/Linaris/Linaris.csproj b/Sources/Linaris/Linaris.csproj index 576c2ee..bbcc06b 100644 --- a/Sources/Linaris/Linaris.csproj +++ b/Sources/Linaris/Linaris.csproj @@ -50,25 +50,40 @@ - + + + + AlbumPage.xaml + + FooterPage.xaml + MSBuild:Compile + + MSBuild:Compile + + + MSBuild:Compile + MSBuild:Compile MSBuild:Compile + + MSBuild:Compile + diff --git a/Sources/Linaris/LocalFilesPage.xaml b/Sources/Linaris/LocalFilesPage.xaml new file mode 100644 index 0000000..b22caac --- /dev/null +++ b/Sources/Linaris/LocalFilesPage.xaml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sources/Linaris/LocalFilesPage.xaml.cs b/Sources/Linaris/LocalFilesPage.xaml.cs new file mode 100644 index 0000000..bf985dd --- /dev/null +++ b/Sources/Linaris/LocalFilesPage.xaml.cs @@ -0,0 +1,9 @@ +namespace Linaris; + +public partial class LocalFilesPage : ContentPage +{ + public LocalFilesPage() + { + InitializeComponent(); + } +} diff --git a/Sources/Linaris/MainPage.xaml b/Sources/Linaris/MainPage.xaml index b0d93e5..357480b 100644 --- a/Sources/Linaris/MainPage.xaml +++ b/Sources/Linaris/MainPage.xaml @@ -1,6 +1,7 @@  @@ -9,6 +10,10 @@ + + + + @@ -21,72 +26,72 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -96,6 +101,8 @@ + + diff --git a/Sources/Linaris/PlaylistPage.xaml b/Sources/Linaris/PlaylistPage.xaml index 843637e..6ba6553 100644 --- a/Sources/Linaris/PlaylistPage.xaml +++ b/Sources/Linaris/PlaylistPage.xaml @@ -1,6 +1,7 @@ @@ -9,6 +10,10 @@ + + + + @@ -84,5 +89,6 @@ + \ No newline at end of file diff --git a/Sources/Linaris/PlaylistsPage.xaml b/Sources/Linaris/PlaylistsPage.xaml index 13ec54c..b1c910d 100644 --- a/Sources/Linaris/PlaylistsPage.xaml +++ b/Sources/Linaris/PlaylistsPage.xaml @@ -1,6 +1,7 @@ @@ -9,6 +10,10 @@ + + + + @@ -21,42 +26,42 @@ - + - + - + - + - + - + - + - + @@ -65,6 +70,8 @@ + + diff --git a/Sources/Linaris/Resources/Images/back.png b/Sources/Linaris/Resources/Images/back.png new file mode 100644 index 0000000..6137b34 Binary files /dev/null and b/Sources/Linaris/Resources/Images/back.png differ diff --git a/Sources/Linaris/Resources/Images/loop.png b/Sources/Linaris/Resources/Images/loop.png new file mode 100644 index 0000000..114f6d8 Binary files /dev/null and b/Sources/Linaris/Resources/Images/loop.png differ diff --git a/Sources/Linaris/Resources/Images/midi.png b/Sources/Linaris/Resources/Images/midi.png new file mode 100644 index 0000000..fd1c356 Binary files /dev/null and b/Sources/Linaris/Resources/Images/midi.png differ diff --git a/Sources/Linaris/Resources/Images/mp3.png b/Sources/Linaris/Resources/Images/mp3.png new file mode 100644 index 0000000..1b8bd4c Binary files /dev/null and b/Sources/Linaris/Resources/Images/mp3.png differ diff --git a/Sources/Linaris/Resources/Images/next.png b/Sources/Linaris/Resources/Images/next.png new file mode 100644 index 0000000..7892cd4 Binary files /dev/null and b/Sources/Linaris/Resources/Images/next.png differ diff --git a/Sources/Linaris/Resources/Images/ogg.png b/Sources/Linaris/Resources/Images/ogg.png new file mode 100644 index 0000000..6d9b3a5 Binary files /dev/null and b/Sources/Linaris/Resources/Images/ogg.png differ diff --git a/Sources/Linaris/Resources/Images/pause.png b/Sources/Linaris/Resources/Images/pause.png new file mode 100644 index 0000000..85dae70 Binary files /dev/null and b/Sources/Linaris/Resources/Images/pause.png differ diff --git a/Sources/Linaris/Resources/Images/play.png b/Sources/Linaris/Resources/Images/play.png new file mode 100644 index 0000000..b8359b0 Binary files /dev/null and b/Sources/Linaris/Resources/Images/play.png differ diff --git a/Sources/Linaris/Resources/Images/rdm.png b/Sources/Linaris/Resources/Images/rdm.png new file mode 100644 index 0000000..7be6cc0 Binary files /dev/null and b/Sources/Linaris/Resources/Images/rdm.png differ diff --git a/Sources/Linaris/Resources/Images/volume.png b/Sources/Linaris/Resources/Images/volume.png new file mode 100644 index 0000000..e1dfb81 Binary files /dev/null and b/Sources/Linaris/Resources/Images/volume.png differ diff --git a/Sources/Linaris/Resources/Images/wav.png b/Sources/Linaris/Resources/Images/wav.png new file mode 100644 index 0000000..6027d2b Binary files /dev/null and b/Sources/Linaris/Resources/Images/wav.png differ diff --git a/Sources/Linaris/Resources/Styles/Styles.xaml b/Sources/Linaris/Resources/Styles/Styles.xaml index 5feaad1..4d38df9 100644 --- a/Sources/Linaris/Resources/Styles/Styles.xaml +++ b/Sources/Linaris/Resources/Styles/Styles.xaml @@ -3,7 +3,9 @@ + xmlns:avatarview="clr-namespace:Syncfusion.Maui.Core;assembly=Syncfusion.Maui.Core" + xmlns:local="clr-namespace:Linaris" + xmlns:test="local:LocalFilesPage"> @@ -96,7 +98,7 @@ -