开发者

How can I determine the length of a local .wav file in JavaScript?

I'd like to get to know the length (best in ms) of a .wav-file with a given file开发者_JS百科path via JavaScript for a GreaseMonkey Script.

Problem 1) accessing local files Problem 2) getting length of the wav


There is jssound from jslibs package that could help you do this quite easily.

 LoadModule('jsstd');
 LoadModule('jsio');
 LoadModule('jssound');

 var file = new File('someSound.wav');
 file.Open('r');
 var pcm = DecodeSound(file);
 file.Close();
 Print('sample length: '+pcm.length, '\n');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜