C# play MP3 file from specified time for the specified time

风流意气都作罢 提交于 2019-12-08 06:19:29

问题


I'm wanting to create a program that you can import an mp3 file into, and tell it to play it starting at a specific position, and to play for a specified amount of time.

I've looked into NAudio, and got it to play and stop the mp3 file, but I can't figure out how to start at a specific position. Anybody know what I should do?


回答1:


If you're using NAudio, look for a Seek method on the output stream -- the information returned from this Google search, http://www.google.com/search?q=seek+site:naudio.codeplex.com, should get you started.

You could also use some old but functional Windows APIs (the MCI interface) as shown here: http://forum.codecall.net/csharp-tutorials/20420-tutorial-playing-mp3-files-c.html demonstrates how to call MCI from C#. MCI uses a very simple string interface, so once you can call it at all it's pretty easy to use any command it supports, and it supports seeking, with the "seek [file] to [position]" command, as shown here: http://www.codeproject.com/KB/audio-video/MP3Example.aspx.



来源:https://stackoverflow.com/questions/4664469/c-sharp-play-mp3-file-from-specified-time-for-the-specified-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!