c# - Getting mp3 file length -


i trying write audio player in c#. using bass library deal playing music have small problem getting length of song.

well have read bass doc , found way: "all" need

int stream = bass.bass_streamcreatefile(filepath,....); int length = bass.bass_channelbytes2seconds(stream, bass.bass_channelgetlength(stream)); 

and in of cases valid length of song. , here problem starts. far know stream creation operation quite expensive (correct me if mistaken) , creating stream length of song looks little silly.

so question is: there other way without creating steam file (not being expensive). thinking later reading id3 tags. creating stream "evil must done no matter what" , if try other library same thing?

you can use microsoft.windowsapicodepack.shell:

using microsoft.windowsapicodepack.shell; 

then code so:

string file = "myfile.mp3" shellfile = shellfile.fromfilepath(file); double 100nanoseconds; double.tryparse(so.properties.system.media.duration.value.tostring(), out 100nanoseconds); 

there code project well


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -