diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2021-02-08 21:27:18 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2021-02-08 21:27:18 -0500 |
| commit | e81e3817c0a4b735da47e6c45529c6f88ed4d52f (patch) | |
| tree | d787a2503a6d4d3c19f9a3c6bced71c61035842a | |
| parent | f5a7e3ef7e25aa2545f541e171f2d5f6fe43ecc7 (diff) | |
| download | erable-godot-e81e3817c0a4b735da47e6c45529c6f88ed4d52f.tar.gz erable-godot-e81e3817c0a4b735da47e6c45529c6f88ed4d52f.tar.bz2 erable-godot-e81e3817c0a4b735da47e6c45529c6f88ed4d52f.zip | |
Moved playback to backend; Menu; Size now matches
| -rw-r--r-- | Erable/Assets/erable.png | bin | 0 -> 76609 bytes | |||
| -rw-r--r-- | Erable/Erable.csproj | 1 | ||||
| -rw-r--r-- | Erable/Program.cs | 13 | ||||
| -rw-r--r-- | Erable/ViewModels/MainWindowViewModel.cs | 33 | ||||
| -rw-r--r-- | Erable/Views/MainWindow.axaml | 23 | ||||
| -rw-r--r-- | Erable/Views/MainWindow.axaml.cs | 7 | ||||
| -rw-r--r-- | Sirop.Backend/Playback.cs | 30 |
7 files changed, 77 insertions, 30 deletions
diff --git a/Erable/Assets/erable.png b/Erable/Assets/erable.png Binary files differnew file mode 100644 index 0000000..1d25b8a --- /dev/null +++ b/Erable/Assets/erable.png diff --git a/Erable/Erable.csproj b/Erable/Erable.csproj index cee2a9c..fa7cecb 100644 --- a/Erable/Erable.csproj +++ b/Erable/Erable.csproj @@ -38,7 +38,6 @@ <PackageReference Include="Avalonia.Diagnostics" Version="0.10.0" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.0" />
<PackageReference Include="Dotnet.Bundle" Version="0.9.13" />
- <PackageReference Include="gstreamer-sharp-netcore" Version="0.0.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Sirop.Backend\Sirop.Backend.csproj" />
diff --git a/Erable/Program.cs b/Erable/Program.cs index 312bbb4..f461a79 100644 --- a/Erable/Program.cs +++ b/Erable/Program.cs @@ -10,11 +10,18 @@ namespace Erable // Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
- public static void Main(string[] args) => BuildAvaloniaApp()
- .StartWithClassicDesktopLifetime(args);
+ public static void Main(string[] args)
+ {
+ Console.WriteLine("Erable: Audio Player by Alee Productions");
+ Console.WriteLine("Running on .NET " + Environment.Version + ", and " + Environment.OSVersion);
+ #if DEBUG
+ Console.WriteLine("Opening MainWindow...");
+ #endif
+ try { BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); }catch (Exception ex) { Console.WriteLine(ex); }
+ }
// Avalonia configuration, don't remove; also used by visual designer.
- public static AppBuilder BuildAvaloniaApp()
+ static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
diff --git a/Erable/ViewModels/MainWindowViewModel.cs b/Erable/ViewModels/MainWindowViewModel.cs index ab41886..899b49c 100644 --- a/Erable/ViewModels/MainWindowViewModel.cs +++ b/Erable/ViewModels/MainWindowViewModel.cs @@ -1,40 +1,26 @@ -using System.Threading;
+using System;
+using System.Threading;
using Avalonia.Controls;
using Erable.Views;
-using Gst;
+using Sirop.Backend;
namespace Erable.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
- public string Greeting => "Welcome to Erable Audio Player!";
public void PlayFunction()
{
- Thread t = new (AudioPlay);
+ Thread t = new (Playback.PlayAudio);
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");
-
- // Start playing
- pipeline.SetState(State.Playing);
- // Wait until error or EOS
- var bus = pipeline.Bus;
- var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.Eos | MessageType.Error);
-
- // Free resources
- pipeline.SetState (State.Null);
+ public void StopFunction()
+ {
}
-
- public async void BrowseFunction()
+ public void BrowseFunction()
{
var dialog = new OpenFileDialog();
// dialog.Title
@@ -61,6 +47,11 @@ namespace Erable.ViewModels {
MessageBox.Show(new MainWindow(), "Hello world", "Test Title", MessageBox.MessageBoxButtons.Ok);
}
+
+ public void Quit()
+ {
+ Environment.Exit(0);
+ }
}
}
diff --git a/Erable/Views/MainWindow.axaml b/Erable/Views/MainWindow.axaml index 02d362a..de6c5b7 100644 --- a/Erable/Views/MainWindow.axaml +++ b/Erable/Views/MainWindow.axaml @@ -5,18 +5,31 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Erable.Views.MainWindow"
- Icon="/Assets/avalonia-logo.ico"
+ Width="800"
+ Height="450"
+ Icon="/Assets/erable.png"
Title="Erable">
<Design.DataContext>
<vm:MainWindowViewModel/>
</Design.DataContext>
<StackPanel>
- <TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
+ <DockPanel>
+ <Menu DockPanel.Dock="Top">
+ <MenuItem Header="_File">
+ <MenuItem Header="_Open..."/>
+ <Separator/>
+ <MenuItem Header="_Exit" PointerPressed="InputElement_OnPointerPressed"/>
+ </MenuItem>
+ <MenuItem Header="_Help">
+ <MenuItem Header="_About"/>
+ </MenuItem>
+ </Menu>
+ </DockPanel>
<Button Name="PlayButton" Width="80" Command="{Binding PlayFunction}" >Play</Button>
- <Button Name="StopButton" Width="80" >Stop</Button>
+ <Button Name="StopButton" Width="80" Command="{Binding StopFunction}">Stop</Button>
<Button Name="BrowseButton" Width="80" Command="{Binding BrowseFunction }" >Browse</Button>
- <Button Name="MessageBoxTest" Width="80" Command="{Binding MsgBoxTest }" >Message Box Test</Button>
-
+ <!--<Button Name="MessageBoxTest" Width="80" Command="{Binding MsgBoxTest }" >Message Box Test</Button>-->
+ <Slider Name="AudioSlider"/>
</StackPanel>
</Window>
diff --git a/Erable/Views/MainWindow.axaml.cs b/Erable/Views/MainWindow.axaml.cs index 814bc0f..78cde38 100644 --- a/Erable/Views/MainWindow.axaml.cs +++ b/Erable/Views/MainWindow.axaml.cs @@ -1,5 +1,7 @@ +using System;
using Avalonia;
using Avalonia.Controls;
+using Avalonia.Input;
using Avalonia.Markup.Xaml;
namespace Erable.Views
@@ -18,5 +20,10 @@ namespace Erable.Views {
AvaloniaXamlLoader.Load(this);
}
+
+ private void InputElement_OnPointerPressed(object? sender, PointerPressedEventArgs e)
+ {
+ Environment.Exit(0);
+ }
}
}
\ No newline at end of file diff --git a/Sirop.Backend/Playback.cs b/Sirop.Backend/Playback.cs new file mode 100644 index 0000000..a073ce3 --- /dev/null +++ b/Sirop.Backend/Playback.cs @@ -0,0 +1,30 @@ +using Gst; + +namespace Sirop.Backend.Audio +{ + public static class Playback + { + public static void PlayAudio() + { + Application.Init(); + // Build the pipeline + var pipeline = Parse.Launch("playbin uri=file:///home/andrew/Music/4616-werq-by-kevin-macleod.mp3"); + + // Start playing + pipeline.SetState(State.Playing); + + // Wait until error or EOS + var bus = pipeline.Bus; + var msg = bus.TimedPopFiltered (Constants.CLOCK_TIME_NONE, MessageType.Eos | MessageType.Error); + + // Free resources + pipeline.SetState (State.Null); + + } + + public static void StopAudio() + { + + } + } +}
\ No newline at end of file |
