You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
1.4 KiB
81 lines
1.4 KiB
12 years ago
|
/*jslint laxbreak:true */
|
||
|
/*jslint laxcomma:true */
|
||
|
/*jslint loopfunc:true */
|
||
|
/*jslint strict:true */
|
||
|
/*jslint browser:true */
|
||
|
/*jslint devel:true */
|
||
|
/**
|
||
|
* TODO: If the user agrees, set the username/passs in a cookie
|
||
|
**/
|
||
|
define([
|
||
|
], function (
|
||
|
) {
|
||
|
"use strict";
|
||
|
|
||
|
var MIMESClass = function() {};
|
||
|
|
||
|
MIMESClass.prototype.get = function (file) {
|
||
|
var fileExtension = '';
|
||
|
var dotPos = 0;
|
||
|
var audioType = undefined;
|
||
|
|
||
|
if ((dotPos = file.indexOf('.')) >= 0) {
|
||
|
fileExtension = file.substring(dotPos + 1);
|
||
|
} else {
|
||
|
fileExtension = file;
|
||
|
}
|
||
|
|
||
|
switch (fileExtension) {
|
||
|
// TODO: Add ogg/flac (video?)
|
||
|
case "mp3":
|
||
|
audioType = "audio/mpeg";
|
||
|
break;
|
||
|
case "au":
|
||
|
case "snd":
|
||
|
audioType = "audio/basic";
|
||
|
break;
|
||
|
case "wav":
|
||
|
audioType = "audio/x-wav";
|
||
|
break;
|
||
|
case "aif":
|
||
|
case "aifc":
|
||
|
audioType = "audio/aiff";
|
||
|
break;
|
||
|
|
||
|
case "m4a":
|
||
|
case "mp4":
|
||
|
case "mp4a":
|
||
|
audioType = "audio/mp4";
|
||
|
break;
|
||
|
|
||
|
case "ogg":
|
||
|
case "oga":
|
||
|
audioType = "audio/ogg";
|
||
|
break;
|
||
|
|
||
|
case "flac":
|
||
|
audioType = "audio/flac";
|
||
|
break;
|
||
|
|
||
|
case "axa":
|
||
|
audioType = "audio/annodex";
|
||
|
break;
|
||
|
|
||
|
case "vorb":
|
||
|
audioType = "audio/vorbis";
|
||
|
break;
|
||
|
|
||
|
case "spx":
|
||
|
audioType = "audio/speex";
|
||
|
break;
|
||
|
|
||
|
default:
|
||
|
console.info('Unknown type: ' + fileExtension);
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return audioType;
|
||
|
};
|
||
|
|
||
|
return new MIMESClass();
|
||
|
});
|