Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio-problem: SoundEffect / SoundEffectInstance - not playing. TypeLoadException.. #5

Open
MortenTantum opened this issue May 14, 2020 · 2 comments

Comments

@MortenTantum
Copy link

Trying to play audio-file in MonoGame - embedded in a WPF-app: Via

SoundEffect _sound = null;
SoundEffectInstance _soundSpil;

It gives me the error below. Anyone know how to solve this issue?

System.TypeLoadException
HResult=0x80131522
Message=Could not load type 'SharpDX.ComObjectCallback' from assembly 'SharpDX, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1'.
Source=MonoGame.Framework
StackTrace:
at Microsoft.Xna.Framework.Audio.SoundEffectInstance.PlatformDispose(Boolean disposing)
at Microsoft.Xna.Framework.Audio.SoundEffectInstance.Dispose(Boolean disposing)
at Microsoft.Xna.Framework.Audio.SoundEffectInstance.Finalize()

The file is silent, not playing...

@MortenTantum
Copy link
Author

And I' tried to use the type Song and play via -
MediaPlayer.Play(song);

But exception is thrown:
InvalidCastException: Unable to cast object of type 'Callback' to type 'SharpDX.IUnknown'.

Anyone got an idea how play sound effects in monogome when embedded in WPF-app?

@damian-666
Copy link

sorry if this is not concise... but theres are so many issues going through and im been through 5 weesk net 6 hell..and almost throught it.im def not downgrading... as this is 2 year LTS... sounds like the monogame conent manager is not in your wpf exe.. or that its missing the .config file at root..
using mg 3,81 , the new content builder needs to be in is in your wpf project.. i updated it to net6i-wnodws in PR.. but i dont konw if yhou will be able to... asslo there must be a .config file at rootl..

you might try Upgrade-assistant, it will mabye fix all your stuff... make a mess , or both.. its a command line too.. press 1.. and enter many times it might go though and fix all your nugets to net 6 compatible ones.. or stayon mg 3.8

I use a shared core that is openGl monogame put the assets in there... then i build shared assets for DX... as in https://github.com/damian-666/MGShadersXPlatform/

Then in my wpf tool it loads content as a sound effect , linked to the mgcb, and usng the wave file as embedded WAV resource in the dll.. or a loose file.... but as DX since the tool is linked to mg content task, and mg DX... if you look at .https://github.com/damian-666/MGShadersXPlatform/ yo will see how to share assets between game and tool... i got from an sample i think its the best way ...

however also i pushed a PR for .net6 sample of wpfcore its not merged but its there, simple aand works.... ( depednignon how much legacy code like docking and 48 stuff yo have... you cant use a net 4.8 wpf and link to a net 6 core lib.. thats is the huge problems i had... ... i could add a wpf too to may shared code sample .

the key is to make sure your assest are shared, linked but compiled for DX and copied to the right place. i havent used song but i use soundeffect..because you can only play one song. I havent got mp3 to work yet .. I embedded the wav files in the content dll...as a resource and load it outsideof content manager as bloated wave files.

because you can only play one song. you cant mix different songs for different characters.. I havent got mp3 to work yet ... i fyou want to play a song you could use the the windowss media player in wpf/ just for your tool for development and then in your came core use the playfofm specific song mndia player in ur game core..The MG song player was reported that it doenst work on IOS tho and has issues... you might be better off using a differnt audio library m not sure... I broke my auido manager into a separate multplatfrom audiomanager code so if i need ot change it i can..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants