10 ["video/mpeg", "mpg"],
11 ["video/quicktime", "mov"],
15 function findMediaFile(tagName, name) {
17 if (tagName == "audio")
22 var element = document.getElementsByTagName(tagName)[0];
24 element = document.createElement(tagName);
26 for (var i = 0; i < codecs.length; ++i) {
27 if (element.canPlayType(codecs[i][0]))
28 return name + "." + codecs[i][1];
34 function mimeTypeForExtension(extension) {
35 for (var i = 0; i < videoCodecs.length; ++i) {
36 if (extension == videoCodecs[i][1])
37 return videoCodecs[i][0];
39 for (var i = 0; i < audioCodecs.length; ++i) {
40 if (extension == audioCodecs[i][1])
41 return audioCodecs[i][0];
47 function mimeTypeForFile(filename) {
48 var lastPeriodIndex = filename.lastIndexOf(".");
49 if (lastPeriodIndex > 0)
50 return mimeTypeForExtension(filename.substring(lastPeriodIndex + 1));
55 function setSrcByTagName(tagName, src) {
56 var elements = document.getElementsByTagName(tagName);
58 for (var i = 0; i < elements.length; ++i)
59 elements[i].src = src;
63 function setSrcById(id, src) {
64 var element = document.getElementById(id);
69 function stripExtension(filename) {
70 var lastPeriodIndex = filename.lastIndexOf(".");
71 if (lastPeriodIndex > 0)
72 return filename.substring(0, lastPeriodIndex);