问题描述
我正在为windows mobile 6.1创建一个应用程序。我想通过我的应用程序播放mp3歌曲。我通过openFileDialog打开mp3歌曲列表,然后选择一个mp3文件。然后我将文件转换为流并尝试使用SoundPlayer播放它。但我发现以下错误。
Wave标头已损坏。
我使用以下代码将文件转换为流并播放流:
currentSoundTrack = ofdSound.FileName;
FileStream fileStream = File.OpenRead(currentSoundTrack);
byte [] fileBytes = new byte [fileStream.Length];
Stream fileStreamNew = new MemoryStream(fileBytes);
SoundPlayer sPlayer = new SoundPlayer(fileStreamNew);
sPlayer.Play();
在sPlayer.Play()之后我收到上述错误。请告诉我这段代码有什么问题?以及我如何使它工作?
Hi,
I am creating an app for windows mobile 6.1. I want to play mp3 songs through my app. I open the mp3 songs list through openFileDialog, and select a mp3 file. Then I convert the the file into stream and tries to play it with SoundPlayer. But I am geting the following error.
"The Wave header is corrupt."
I am using following code to convert the file into stream and playing the stream :
currentSoundTrack = ofdSound.FileName;
FileStream fileStream = File.OpenRead(currentSoundTrack);
byte[] fileBytes = new byte[fileStream.Length];
Stream fileStreamNew = new MemoryStream(fileBytes);
SoundPlayer sPlayer = new SoundPlayer(fileStreamNew);
sPlayer.Play();
An after sPlayer.Play() I am getting the above error. Please tell me what is the problem with this code? and how I can make it to work ?
推荐答案
这篇关于如何通过编码在windows mobile 6.1中播放mp3文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!