Add lbry.getMediaType()
This commit is contained in:
parent
2824447c6c
commit
ecc20adaa9
1 changed files with 20 additions and 0 deletions
20
js/lbry.js
20
js/lbry.js
|
@ -170,6 +170,26 @@ lbry.imagePath = function(file)
|
|||
return lbry.rootPath + '/img/' + file;
|
||||
}
|
||||
|
||||
lbry.getMediaType = function(filename) {
|
||||
var dotIndex = filename.lastIndexOf('.');
|
||||
if (dotIndex == -1) {
|
||||
return 'unknown';
|
||||
}
|
||||
|
||||
var ext = filename.substr(dotIndex + 1);
|
||||
if (/^mp4|mov|m4v|flv|f4v$/i.test(ext)) {
|
||||
return 'video';
|
||||
} else if (/^mp3|m4a|aac|wav|flac|ogg$/i.test(ext)) {
|
||||
return 'audio';
|
||||
} else if (/^html|htm|pdf|odf|doc|docx|md|markdown|txt$/i.test(ext)) {
|
||||
return 'document';
|
||||
} else {
|
||||
return 'unknown';
|
||||
}
|
||||
}
|
||||
|
||||
lbry.stop = function(callback) {
|
||||
lbry.call('stop', {}, callback);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue