blob: ab418865b2d619bac3cc164497cc539a8ad17e1f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
using System.Threading;
using Avalonia.Controls;
using Erable.Views;
using Gst;
namespace Erable.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
public string Greeting => "Welcome to Erable Audio Player!";
public void PlayFunction()
{
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");
// 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 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 MsgBoxTest()
{
MessageBox.Show(new MainWindow(), "Hello world", "Test Title", MessageBox.MessageBoxButtons.Ok);
}
}
}
|