Whenever I try to load and play a file, my app crashes and I get a null reference exception.
This is my code:
ISimpleAudioPlayer player;
public void OnPlay()
{
player = CrossSimpleAudioPlayer.CreateSimpleAudioPlayer();
player.Load(GetStreamFromFile("Make Me Glow.mp3"));
player.Play();
}
Stream? GetStreamFromFile(string filename)
{
var assembly = typeof(App).GetTypeInfo().Assembly;
var stream = assembly.GetManifestResourceStream("TestMVVM." + filename);
return stream;
}
public void OnPause()
{
player.Pause();
}
public void OnResume()
{
player.Play();
}
public void OnStop()
{
player.Stop();
}
I would guess this has something to do with me using Avalonia UI, I just wanted to make sure that I wasn't missing something.
Any help would be greatly appreciated. :)
Whenever I try to load and play a file, my app crashes and I get a null reference exception. This is my code:
I would guess this has something to do with me using Avalonia UI, I just wanted to make sure that I wasn't missing something. Any help would be greatly appreciated. :)