Wally_the_Walrus
Wally_the_Walrus

Reputation: 219

Media player c# playing from network

I´m trying to play a file located on network at address:

string filePath = @"\\192.168.xx.xx\folder\folder2\Audio\audio.wav";

and trying to play it in MediaPlayer.MediaPlayer player like this:

m_player = new MediaPlayer();
m_player.Stop();
m_player.Open(new Uri(path));
m_player.Play();

It doesn't return any exception, but it also does not play the sound. When I copy the file on a local disk and try to play it, it works fine.

Any ideas where the problem could be?

Upvotes: 2

Views: 2359

Answers (2)

Chazt3n
Chazt3n

Reputation: 1651

The SoundPlayer class can do this. It looks like all you have to do is set its Stream property to the stream, then call Play.

Upvotes: 0

Matthias
Matthias

Reputation: 5764

Doing some Google says, that you should try a relative Uri.

m_player = new MediaPlayer();
m_player.Stop();
m_player.Open(new Uri(path, UriKind.Relative));
m_player.Play();

Otherwise have a look at this example, which opens a stream and sets the stream to the MediaPlayer.

Upvotes: 1

Related Questions