parsley72
parsley72

Reputation: 9037

Play sound from WAV file at a time offset from start in C#

I'm trying to coordinate playing sound with displaying some other data on a graph recorded at the same time. If the user drags the graph forward or backwards how can I skip forward or backward in the WAV file so the sound is still coordinated? I can't see a time offset in APIs like SoundPlayer.

Upvotes: 2

Views: 1448

Answers (2)

YazX
YazX

Reputation: 521

if i understood your question correctly, then use WMPLib.WindowsMediaPlayer , add reference to "Windows Media Player" from COM and then you set the position by using:

 WMPLib.WindowsMediaPlayer player = new  WMPLib.WindowsMediaPlayer();
 player.URL = file; //file to be played
 player.controls.play();
 player.controls.currentPosition = x; //set the position you want here when user drag

or you can use naudio, free opensource API, download it from codeplex:

Naudio Library

Upvotes: 1

btevfik
btevfik

Reputation: 3431

Seems like you can't skip backward or forward using SoundPlayer.

Windows Form: Play sound, but not from beginning

C# - Get time from soundplayer

Upvotes: 1

Related Questions