diff --git a/Sources/Linaris/FooterPage.xaml b/Sources/Linaris/FooterPage.xaml
index c71d0b8..f1ad801 100644
--- a/Sources/Linaris/FooterPage.xaml
+++ b/Sources/Linaris/FooterPage.xaml
@@ -18,11 +18,11 @@
-
+
-
+
diff --git a/Sources/Linaris/FooterPage.xaml.cs b/Sources/Linaris/FooterPage.xaml.cs
index 97ebfa0..1bd4920 100644
--- a/Sources/Linaris/FooterPage.xaml.cs
+++ b/Sources/Linaris/FooterPage.xaml.cs
@@ -1,4 +1,5 @@
using NAudio.Wave;
+using Plugin.Maui.Audio;
namespace Linaris;
@@ -24,11 +25,23 @@ public partial class FooterPage : ContentView
outputDevice.Init(audioFile);*/
}
+ public void PlayAudio(string path)
+ {
+ using (var stream = File.OpenRead(path))
+ {
+ var audioPlayer = AudioManager.Current.CreatePlayer(stream);
+ audioPlayer.Volume = 100.0f;
+ audioPlayer.Play();
+ }
+ }
+
public void PlayButton_Clicked(object sender, EventArgs e)
{
- Play();
- /*string url = ((FileImageSource)Play.Source).File;
- if (url == "play.png")
+ string CurrentPath = (Application.Current as App).Manager.CurrentPlaying.Path;
+ if (CurrentPath == null) return;
+ PlayAudio(CurrentPath);
+ /*string url = ((FileImageSource)Play.Source).File;*/
+ /*if (url == "play.png")
{
outputDevice?.Play();
Play.Source = "pause.png";
@@ -44,11 +57,6 @@ public partial class FooterPage : ContentView
}*/
}
- public void Play()
- {
- if ((Application.Current as App).Manager.CurrentPlaying == null) return;
- }
-
public void RewindButton_Clicked(Object sender, EventArgs e)
{
/*audioFile.Position = 0;
diff --git a/Sources/Linaris/MainPage.xaml b/Sources/Linaris/MainPage.xaml
index 76cae65..9837833 100644
--- a/Sources/Linaris/MainPage.xaml
+++ b/Sources/Linaris/MainPage.xaml
@@ -14,7 +14,9 @@
-
+
+
+
diff --git a/Sources/Linaris/MainPage.xaml.cs b/Sources/Linaris/MainPage.xaml.cs
index 6893055..72f76fb 100644
--- a/Sources/Linaris/MainPage.xaml.cs
+++ b/Sources/Linaris/MainPage.xaml.cs
@@ -6,6 +6,8 @@ namespace Linaris;
public partial class MainPage : ContentPage
{
+ private readonly IAudioManager audioManager;
+
private readonly ObservableCollection albums = (Application.Current as App).Manager.GetAlbums();
public ObservableCollection Albums
@@ -13,10 +15,11 @@ public partial class MainPage : ContentPage
get => albums;
}
- public MainPage()
+ public MainPage(IAudioManager audioManager)
{
InitializeComponent();
BindingContext = this;
+ this.audioManager = audioManager;
}
async void GoToAlbum(object sender, EventArgs e)
@@ -30,5 +33,37 @@ public partial class MainPage : ContentPage
}
}
}
+
+ public void PlayAudio(string path)
+ {
+ using (var stream = File.OpenRead(path))
+ {
+ var audioPlayer = audioManager.CreatePlayer(stream);
+ audioPlayer.Volume = 1.0f;
+ audioPlayer.Play();
+ }
+ }
+
+ public void play(object sender, EventArgs e)
+ {
+ string CurrentPath = (Application.Current as App).Manager.CurrentPlaying.Path;
+ if (CurrentPath == null) return;
+ PlayAudio(CurrentPath);
+ /*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";
+ }*/
+ }
}
diff --git a/Sources/Linaris/PlaylistPage.xaml.cs b/Sources/Linaris/PlaylistPage.xaml.cs
index 5839f99..a741e82 100644
--- a/Sources/Linaris/PlaylistPage.xaml.cs
+++ b/Sources/Linaris/PlaylistPage.xaml.cs
@@ -35,16 +35,7 @@ public partial class PlaylistPage : ContentPage
{
(Application.Current as App).Manager.CurrentPlaying = playlist.Titles.FirstOrDefault();
if ((Application.Current as App).Manager.CurrentPlaying == null) return;
-
- /*if (button.Parent.Parent.Parent.Parent.Parent is Grid grid)
- {
- grid.RowDefinitions.Clear();
- RowDefinition row1 = new RowDefinition();
- RowDefinition row2 = new RowDefinition();
- row2.Height = 100;
- grid.RowDefinitions.Add(row1);
- grid.RowDefinitions.Add(row2);
- }*/
+ (Application.Current as App).Manager.Play();
}
}
}
diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs
index 5cf228b..5264b8a 100644
--- a/Sources/Model/Manager.cs
+++ b/Sources/Model/Manager.cs
@@ -128,6 +128,12 @@ public class Manager
currentAlbum = albums.First();
currentPlaylist = playlists.FirstOrDefault();
currentInfoTitle = infoTitles.FirstOrDefault();
+ currentPlaying = null;
+ }
+
+ public void Play()
+ {
+
}
public void AddAlbum(Album album)
diff --git a/Sources/Model/Model.csproj b/Sources/Model/Model.csproj
index 1645254..5e08cad 100644
--- a/Sources/Model/Model.csproj
+++ b/Sources/Model/Model.csproj
@@ -19,4 +19,4 @@
6.5
-
+
\ No newline at end of file
diff --git a/Sources/Model/Serialization/LINQ_XML_Serialization.cs b/Sources/Model/Serialization/LINQ_XML_Serialization.cs
index a3e4bab..9420614 100644
--- a/Sources/Model/Serialization/LINQ_XML_Serialization.cs
+++ b/Sources/Model/Serialization/LINQ_XML_Serialization.cs
@@ -2,7 +2,6 @@
using System.Xml.Linq;
using System.Collections.ObjectModel;
using Model.Stub;
-using Microsoft.Maui.Storage;
namespace Model.Serialization;
diff --git a/Sources/TestUnitaires/TU_Manager.cs b/Sources/TestUnitaires/TU_Manager.cs
index 026112e..850fb5a 100644
--- a/Sources/TestUnitaires/TU_Manager.cs
+++ b/Sources/TestUnitaires/TU_Manager.cs
@@ -15,11 +15,10 @@ namespace TestUnitaires
[InlineData("Réference")]
public void TU_Methods(string? test)
{
- IDataManager DataManager = new LinqXmlSerialization();
Playlist p = new Playlist(test, "PlaceHolder", "place.holder");
Album album = new Album(test, "place.holder", new Artist("test"), "PlaceHolder", "PlaceHolder");
CustomTitle t = new CustomTitle(test, "test. mp3", "Banger", "path");
- Manager m = new Manager(DataManager);
+ Manager m = new Manager(new LinqXmlSerialization());
m.AddCustomTitle(t);
m.AddPlaylist(p);
m.AddAlbum(album);