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');
精彩评论