Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Playing sound from Database using MediaPlayer C#

I have sound stored in database in byte[] type. I can easily play with SoundPlayer, but not with MediaPlayer. Nice thing about MediaPlayer is I can play from middle of the sound. SoundPlayer doesn't have this feature. Is there way to play sound which stored in database with MediaPlayer(not from the filesystem). Any help appreciated.

like image 409
Dilshod Avatar asked Jan 24 '26 00:01

Dilshod


1 Answers

Unfortunately the MediaPlayer class can only Open media from the file system - it's simply a limitation. It's only option is to receive a Uri. However, I would recommend leveraging NAudio. With NAudio you can in fact play, pause, stop, rewind, and more all in memory.

like image 198
Mike Perrenoud Avatar answered Jan 26 '26 15:01

Mike Perrenoud