tags:

views:

447

answers:

5

With C#, How do I play (Pause, Forward...) a sound file (mp3, ogg) ? The file could be on the hard disk, or on the internet.

Is there any library or Class out there that can ease me the work ?

Thanks

A: 

use PlaySound API call

Steven A. Lowe
+3  A: 

If you don't mind including Microsoft.VisualBasic.dll in your project, you can do it this way:

var audio = new Microsoft.VisualBasic.Devices.Audio();
audio.Play("some file path");

If you want to do more complex stuff, the easiest way I know of is to use the Windows Media Player API. You add the DLL and then work with it. The API is kind of clunky, but it does work; I've used it to make my own music player wrapper around Windows Media Player for personal use. Here are some helpful links to get you started:

Building a Web Site with ASP .NET 2.0 to Navigate Your Music Library

Windows Media Object Model

Let the Music Play!

Kyralessa
+3  A: 

I would recommend the BASS Library. It can play both filebased music files and streaming content. There is also a .NET wrapper available.

Magnus Johansson
Yeah, I saw that. There's even a Codeproject article on nBass ( a class wrapper of Bass). It's easy how it's done, but he do use an old version of Bass (v1.8), I'm looking for the version he used, hope I can download it.
Black Horus
A: 

There's a media player control - basically what Media Player uses. You can put that in your program and there's an API you can use to control it. I think it's the best quick solution.

kokos
A: 

Please download http://alvas.net/Download/Alvas.Audio.zip and see RecordPlay example

ava