|
|
|
@ -6,6 +6,8 @@ namespace Linaris;
|
|
|
|
|
|
|
|
|
|
public partial class MainPage : ContentPage
|
|
|
|
|
{
|
|
|
|
|
private readonly IAudioManager audioManager;
|
|
|
|
|
|
|
|
|
|
private readonly ObservableCollection<Album> albums = (Application.Current as App).Manager.GetAlbums();
|
|
|
|
|
|
|
|
|
|
public ObservableCollection<Album> 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";
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|