Display Music File Type
xRadio-us opened this issue · 4 comments
Most people do not need to see whether the music file is MP3, OGG or WAV. However, that is important to me. I am currently evaluating and comparing audio pronunciation clips in several formats to add to a test web site Time-Place-Pronounce that I am developing.
Since your music.php results show the file extension, I assume that this can be modified somewhere in your music.js file. Maybe you can point to where I can make code changes.
If you add this feature, one could either display the extension type or colorize the filename depending on the audio file type.
Sure! In music.js, search for
function getSong(path) {
return path.substring(path.lastIndexOf('/') + 1, path.lastIndexOf('.'));
}
and replace it with
function getSong(path) {
return path.substring(path.lastIndexOf('/') + 1);
}
That's all!
I decided to only display the extension for non-MP3 files (M4A, OGG, WAV, etc.).
function getSong(path) {
var x = path.lastIndexOf('.');
var ext = path.substring(x).toLowerCase();
var name = path.substring(path.lastIndexOf('/') + 1,x);
if(ext != '.mp3') name += ext.replace('.',' . ');
return name;
}
I updated to replace WAV, OGG and M4A with raised symbols. Unfortunately, I had to cut and paste the actual raised W, degree, and raised 4 symbols since HTML ENTITY code style was not decoded.
if(ext != '.mp3') name += ext.replace('.wav',' ᵂ').replace('.ogg',' °').replace('m4a','⁴');
Well, if it works, it works ;-) Nicely done!