aboutsummaryrefslogtreecommitdiff
path: root/Erable/ViewModels/MainWindowViewModel.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2021-02-08 00:00:49 -0500
committerAndrew Lee <alee14498@protonmail.com>2021-02-08 00:00:49 -0500
commitf5a7e3ef7e25aa2545f541e171f2d5f6fe43ecc7 (patch)
tree6f5dbb64c68ff3bf8a2cd771366ac5ff466d183d /Erable/ViewModels/MainWindowViewModel.cs
parentc7428fab1c38d29bcc50ee263678504e34d01318 (diff)
downloaderable-godot-f5a7e3ef7e25aa2545f541e171f2d5f6fe43ecc7.tar.gz
erable-godot-f5a7e3ef7e25aa2545f541e171f2d5f6fe43ecc7.tar.bz2
erable-godot-f5a7e3ef7e25aa2545f541e171f2d5f6fe43ecc7.zip
Erable playing audio in bg thread; Sirop backend initalized; Msgbox added
Diffstat (limited to 'Erable/ViewModels/MainWindowViewModel.cs')
-rw-r--r--Erable/ViewModels/MainWindowViewModel.cs48
1 files changed, 39 insertions, 9 deletions
diff --git a/Erable/ViewModels/MainWindowViewModel.cs b/Erable/ViewModels/MainWindowViewModel.cs
index 0c51fbd..ab41886 100644
--- a/Erable/ViewModels/MainWindowViewModel.cs
+++ b/Erable/ViewModels/MainWindowViewModel.cs
@@ -1,7 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Threading;
using Avalonia.Controls;
+using Erable.Views;
using Gst;
namespace Erable.ViewModels
@@ -10,9 +9,15 @@ namespace Erable.ViewModels
{
public string Greeting => "Welcome to Erable Audio Player!";
- public void PlayFunction(string[] args)
+ public void PlayFunction()
{
- Application.Init(ref args);
+ Thread t = new (AudioPlay);
+ t.Start();
+ }
+
+ static void AudioPlay()
+ {
+ Application.Init();
// Build the pipeline
var pipeline = Parse.Launch("playbin uri=file:///home/andrew/Music/4616-werq-by-kevin-macleod.mp3");
@@ -24,13 +29,38 @@ namespace Erable.ViewModels
var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.Eos | MessageType.Error);
// Free resources
- //pipeline.SetState (State.Null);
+ pipeline.SetState (State.Null);
+
+ }
+
+
+ public async void BrowseFunction()
+ {
+ var dialog = new OpenFileDialog();
+ // dialog.Title
+ dialog.Filters.Add(new FileDialogFilter() {Name = "Audio Files", Extensions = {"mp3", "wav", "flac"}});
+ dialog.Title = "Select Audio FIle";
+ /*
+ var files = await dialog.ShowAsync(this);
+
+ if(files != null && files.Length > 0)
+ {
+ var file = files[0];
+ if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows))
+ {
+ PlayFunction($"file:/{file.Replace('\\', '/')}");
+ }
+ else
+ {
+ PlayFunction($"file://{file}");
+ }
+ }*/
}
- public void BrowseFunction()
+ public void MsgBoxTest()
{
- //OpenFileDialog dialog = new OpenFileDialog();
- //dialog.Filters.Add(new FileDialogFilter() {Name = "Audio Files", Extensions = {"mp3"}});
+ MessageBox.Show(new MainWindow(), "Hello world", "Test Title", MessageBox.MessageBoxButtons.Ok);
}
+
}
}