|
|
|
@ -4,29 +4,29 @@ namespace Linaris;
|
|
|
|
|
|
|
|
|
|
public partial class FooterPage : ContentView
|
|
|
|
|
{
|
|
|
|
|
WaveOutEvent outputDevice;
|
|
|
|
|
/*WaveOutEvent outputDevice;
|
|
|
|
|
AudioFileReader audioFile;
|
|
|
|
|
System.Timers.Timer timer;
|
|
|
|
|
bool changementManuel = true;
|
|
|
|
|
bool closing = false;
|
|
|
|
|
string morceauEnCours;
|
|
|
|
|
string morceauEnCours;*/
|
|
|
|
|
|
|
|
|
|
public FooterPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
outputDevice = new WaveOutEvent();
|
|
|
|
|
/*outputDevice = new WaveOutEvent();*/
|
|
|
|
|
|
|
|
|
|
// (s,a) = convention, s = sender, a = arguments, si appli fermée, on free tout
|
|
|
|
|
outputDevice.PlaybackStopped += PlaybackStoppedHandler;
|
|
|
|
|
/*outputDevice.PlaybackStopped += PlaybackStoppedHandler;
|
|
|
|
|
|
|
|
|
|
morceauEnCours = Path.Combine(AppContext.BaseDirectory, "Resources", "Musics", "winter.mp3");
|
|
|
|
|
audioFile = new AudioFileReader(morceauEnCours);
|
|
|
|
|
outputDevice.Init(audioFile);
|
|
|
|
|
outputDevice.Init(audioFile);*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PlayButton_Clicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string url = ((FileImageSource)Play.Source).File;
|
|
|
|
|
/*string url = ((FileImageSource)Play.Source).File;
|
|
|
|
|
if (url == "play.png")
|
|
|
|
|
{
|
|
|
|
|
outputDevice?.Play();
|
|
|
|
@ -40,39 +40,39 @@ public partial class FooterPage : ContentView
|
|
|
|
|
{
|
|
|
|
|
outputDevice?.Pause();
|
|
|
|
|
Play.Source = "play.png";
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RewindButton_Clicked(Object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
audioFile.Position = 0;
|
|
|
|
|
/*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;
|
|
|
|
|
timer.Enabled = true;*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void NextButton_Clicked(Object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
audioFile.Position = audioFile.Length;
|
|
|
|
|
/*audioFile.Position = audioFile.Length;*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void StopButton_Clicked(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
outputDevice.Stop();
|
|
|
|
|
audioFile.Position = 0;
|
|
|
|
|
/*outputDevice.Stop();
|
|
|
|
|
audioFile.Position = 0;*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Slider_ValueChanged(object sender, ValueChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
outputDevice.Volume = (float)e.NewValue;
|
|
|
|
|
/*outputDevice.Volume = (float)e.NewValue;*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Bar_ValueChanged(object sender, ValueChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (changementManuel)
|
|
|
|
|
/*if (changementManuel)
|
|
|
|
|
{
|
|
|
|
|
double totalSeconds = audioFile.TotalTime.TotalSeconds;
|
|
|
|
|
double newPosition = e.NewValue * totalSeconds;
|
|
|
|
@ -82,12 +82,12 @@ public partial class FooterPage : ContentView
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
changementManuel = true;
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PlaybackStoppedHandler(object sender, StoppedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (closing)
|
|
|
|
|
/*if (closing)
|
|
|
|
|
{
|
|
|
|
|
outputDevice.Dispose();
|
|
|
|
|
audioFile.Dispose();
|
|
|
|
@ -95,12 +95,12 @@ public partial class FooterPage : ContentView
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Play.Dispatcher.Dispatch(() => Play.Source = "play.png");
|
|
|
|
|
}
|
|
|
|
|
}*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Timer_Elapsed(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TimeSpan totalTimeSpan = audioFile.TotalTime;
|
|
|
|
|
/*TimeSpan totalTimeSpan = audioFile.TotalTime;
|
|
|
|
|
TimeSpan currentTimeSpan = audioFile.CurrentTime;
|
|
|
|
|
|
|
|
|
|
string totalTimeFormatted = totalTimeSpan.ToString(@"hh\:mm\:ss");
|
|
|
|
@ -110,17 +110,17 @@ public partial class FooterPage : ContentView
|
|
|
|
|
|
|
|
|
|
bar.Dispatcher.Dispatch(() => bar.Value = audioFile.CurrentTime.TotalSeconds / audioFile.TotalTime.TotalSeconds);
|
|
|
|
|
currentTime.Dispatcher.Dispatch(() => currentTime.Text = currentTimeFormatted);
|
|
|
|
|
endTime.Dispatcher.Dispatch(() => endTime.Text = totalTimeFormatted);
|
|
|
|
|
endTime.Dispatcher.Dispatch(() => endTime.Text = totalTimeFormatted);*/
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadNewAudioFile(string filePath)
|
|
|
|
|
{
|
|
|
|
|
if (outputDevice.PlaybackState == PlaybackState.Playing)
|
|
|
|
|
/*if (outputDevice.PlaybackState == PlaybackState.Playing)
|
|
|
|
|
{
|
|
|
|
|
outputDevice.Stop();
|
|
|
|
|
}
|
|
|
|
|
audioFile = new AudioFileReader(filePath);
|
|
|
|
|
outputDevice.Init(audioFile);
|
|
|
|
|
outputDevice.Init(audioFile);*/
|
|
|
|
|
}
|
|
|
|
|
}
|