12 function findMediaFile(tagName, name) {
14 if (tagName == "audio")
19 var element = document.getElementsByTagName(tagName)[0];
21 element = document.createElement(tagName);
23 for (var i = 0; i < codecs.length; ++i) {
24 if (element.canPlayType(codecs[i][0]))
25 return name + "." + codecs[i][1];
31 function mimeTypeForExtension(extension) {
32 for (var i = 0; i < videoCodecs.length; ++i) {
33 if (extension == videoCodecs[i][1])
34 return videoCodecs[i][0];
36 for (var i = 0; i < audioCodecs.length; ++i) {
37 if (extension == audioCodecs[i][1])
38 return audioCodecs[i][0];
44 function mimeTypeForFile(filename) {
45 var lastPeriodIndex = filename.lastIndexOf(".");
46 if (lastPeriodIndex > 0)
47 return mimeTypeForExtension(filename.substring(lastPeriodIndex + 1));
52 function setSrcByTagName(tagName, src) {
53 var elements = document.getElementsByTagName(tagName);
55 for (var i = 0; i < elements.length; ++i)
56 elements[i].src = src;
60 function setSrcById(id, src) {
61 var element = document.getElementById(id);
66 function stripExtension(filename) {
67 var lastPeriodIndex = filename.lastIndexOf(".");
68 if (lastPeriodIndex > 0)
69 return filename.substring(0, lastPeriodIndex);