Reputation: 8833
I'm trying to use UrhoSharp in my Xamarin application to play sound, but SoundSource seems to need Urho to be initialized, and I can't initialize Urho without errors.
Here is the code I am trying to run
public void PlayTestUrho()
{
using (System.IO.Stream wav_stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(wav_file_name))
using (System.IO.MemoryStream mem_stream = new System.IO.MemoryStream())
{
wav_stream.CopyTo(mem_stream);
Node node = new Node();
SoundSource src = node.CreateComponent<SoundSource>();
BufferedSoundStream soundStream = new BufferedSoundStream();
soundStream.AddData(mem_stream.ToArray());
soundStream.SetFormat(44100, true, true);
src.AutoRemoveMode = AutoRemoveMode.Node;
src.Enabled = true;
src.Panning = panning;
src.Gain = gain;
src.Frequency = frequency;
src.Play(soundStream);
}
}
However, when I run that, I get the following error message
Urho.Application is not started yet. All urho objects should be initialized after app.Run() since they need an active Context.
I tried adding the line Urho.Application.CreateInstance(typeof(Urho.SimpleApplication)).Run();
(the closest thing to Urho.app.Run() I could find) in my App.xaml.cs constructor, but that line gives me this error message
Failed to initialise SDL subsystem: Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?. You can omit this exception by subscribing to Urho.Application.UnhandledException event and set Handled property to True.
The only help I can find is the SoundSynthesis sample, but it seems all the samples assume all boilerplate overhead has been taken care. (I am also probably loading the wav file wrong, but I can worry about that after I get Urho to even try playing it)
Upvotes: 1
Views: 240