Decoding ogg files to wav in WP8

770 Views Asked by At

I want to convert ogg file to wav and then play it on wp8 devives. I've already checked many solutions but none of them worked. This looks promising but something doesn't work:

string _audioPath = "/SomeProject;component/Sounds/a_dog.ogg";
var stream = Application.GetResourceStream(new Uri(_audioPath, UriKind.Relative)).Stream;
using (var vorbis = new NVorbis.VorbisReader(stream, true))
        {
            float[] buf = new float[vorbis.TotalSamples];
            vorbis.ReadSamples(buf, 0, (int)vorbis.TotalSamples);
        }

When I execute it I see FileNotFoundException at VorbisReader contruction. I also checked if stream is readable and it is. I was able to get the file content using Read method.

Do you have any ideas why it doesn't work? Maybe you know some other library for wp8 which can decode ogg files?

[EDIT] I downloaded source code of NVorbis and used it directly from my project, and when i do this I don't get any FileNotFoundExceptions and everything seems to work. Maybe this exception is caused by missing library? I've got NVorbis reference added...

1

There are 1 best solutions below

11
On

I think you are running into the same issue as this guy. Short version: I believe your Pack URI should be "pack://application:,,,/SomeProject;Component/Sounds/a_dog.ogg". NVorbis is not actually throwing the exception itself, but is instead causing the resource stream to do so...