Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Created Unassigned: Unable to open m4a/aac/wma files in Unity [16475]

$
0
0
I'm currently making a music game in Unity which requires me to load arbitrary music files at runtime. I've used NAudio successfully to support mp3s; however, m4a files (and anything else that uses MediaFoundationReader) causes NAudio to hang inexplicably.

This line of code causes the problem:

var audioFileReader = new AudioFileReader(fileName);

The strange thing is that this works fine in the NAudio demo. I tried porting the Demo code straight up to Unity, but the same code that works perfectly in the demo causes a hang inside Unity.

After some debugging, I tracked it down to this function:

protected virtual IMFSourceReader CreateReader(MediaFoundationReaderSettings settings)
{
IMFSourceReader reader;
MediaFoundationInterop.MFCreateSourceReaderFromURL(file, null, out reader);
__reader.SetStreamSelection(MediaFoundationInterop.MF_SOURCE_READER_ALL_STREAMS, false);__

That last line fails to execute, Unity freezes and never resumes.

A quick lookup on MSDN has this to say:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd374655(v=vs.85).aspx

Minimum supported client
Windows 7, Windows Vista and Platform Update Supplement for Windows Vista [desktop apps | Windows Store apps]

I am running Windows 8. My current fear is that Unity's Mono implementation simply doesn't support this at all and I cannot use any Media Foundation classes.

Any insight would be strongly appreciated.

Repro steps:

1. Setup an empty Unity project (I'm using Unity 5, version shouldn't matter)
2. Import NAudio
3. Have a simple script that tries to load a .m4a file using NAudio
4. Unity hangs and crashes.

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>