views:

162

answers:

3

I tried fmod.net but got a 'System.BadImageFormatException' error. I then tried WindowsMediaPlayer and have sounds playing. However i am having issues playing a sound when the current one ends (callback code below. It doesnt seem to like me playing a new song during a state change however i cant find another way to inform me when the song is done) and using this link i was able to get title but not artist, album etc.

What lib can i use to play back sound (mp3, m4a and i would like ogg and aac). I looked up FFMPEG.NET and found a project with no release and another called fflib which seems to do conversions only (and also had the bad image exception). What may i use? or How do i get the title/artist/etc in WMPLib.WindowsMediaPlayer and have it play another song when one ends (i do not want to add a playlist inside of WMP. I'd like to maintain it and just be notified when a song ends to do further actions).

    private void Player_PlayStateChange(int NewState)
    {
        var newState = (WMPLib.WMPPlayState)NewState;
        Console.WriteLine(newState);
        //if (newState == WMPLib.WMPPlayState.wmppsMediaEnded)
        if (newState == WMPLib.WMPPlayState.wmppsStopped)
        {
            next();
        }
    }
+2  A: 

You can use NAudio on Codeplex.

Josh Einstein
+1  A: 

Have you tried Bass.Net?

arifwn
+4  A: 

The 'System.BadImageFormatException' is caused by using libraries for different platforms. If the library you use is x86, you have to set your target platform to x86, not Any CPU (assume running on x64).

Igor
Thank you! This solved my fmod problem! :D
acidzombie24
This is odd, you'd expect that WMP would determine the bitness of the process. +1 anyway, it is the right diagnostic.
Hans Passant
@AcidZombie24 don't forget to mark as answered if Igor answered your question.
Josh Einstein
@Josh: Even tho igor solved my problem the main question sadly is What lib to use. I may make this into a wiki and i dont mark as accept in wikis
acidzombie24
@nobugz: On x64 OS (Vista, Windows 7) you’ve got two versions of VWP. 32bit (Program Files(x86)) and 64bit (Program Files) version. So if you run the 32bit version you have to use 32bit binaries (on 64bit OS). The ‘Any CPU’ is a feature from managed world, where the runtime (JIT) decide how to create binaries from the IL based on OS (it does not care about the executing process).
Igor