Pergunta

I'm very new to C#, MonoMac and Xamarin and am trying to play some generated audio with C# and Xamarin.Mac using this awesome example.

Unforunately the first line:

AudioSession.Initialize();

throws an EntryPointNotFoundException.

I've stumbled upon this forum post where someone is having a similar problem and suggests that it has to do with an incorrect binding.

Can I actually get this to work? If not, what can I use instead?

Thank you so much for your help.

My System

Xamarin.Mac: 1.2.43

Xamarin.Studio Version 4.0.3 (build 13)

Mono 2.10.12 (mono-2-10/c9b270d)

GTK 2.24.16

GTK# (2.12.0.0)

Package version: 210120000

Stack Trace

System.EntryPointNotFoundException: AudioSessionInitialize
  at at (wrapper managed-to-native) MonoMac.AudioToolbox.AudioSession.AudioSessionInitialize (intptr,intptr,MonoMac.AudioToolbox.AudioSession/InterruptionListener,intptr) <IL 0x00011, 0x0007b>
  at MonoMac.AudioToolbox.AudioSession.Initialize (MonoMac.CoreFoundation.CFRunLoop,string) [0x00013] in /Users/builder/data/lanes/xamcore-lion-bs1/0c83ca0e/source/xamcore/maccore/src/AudioToolbox/AudioSession.cs:225
Foi útil?

Solução

I think that AudioSession is not used on OS X.

The sample code you are working from is likely for iOS.

If you check the documentation for AudioSession, you will see:

These functions apply only to iOS. They do not apply to Mac OS X.

Additionally, see this discussion. AudioSession is simply not available, which is why you get EntryPointNotFoundException when trying to call it...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top