Skip to content

Instantly share code, notes, and snippets.

@bdotdub
Created December 13, 2008 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdotdub/35516 to your computer and use it in GitHub Desktop.
Save bdotdub/35516 to your computer and use it in GitHub Desktop.
Test page for patch http://gist.github.com/35493
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>canPlayUrl Test</title>
<script src="soundmanager2.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
soundManager.debugMode = false;
function runTests() {
var url = "http://freshly-ground.com/misc/music/carl-3-barlp.mp3";
is(soundManager.canPlayURL(url), true, "Plain URL", url);
url = "http://freshly-ground.com/misc/music/carl-3-barlp.mp3?key=value";
is(soundManager.canPlayURL(url), true, "URL with parameters", url);
url = "http://freshly-ground.com/misc/mp3/carl-3-barlp.mp3";
is(soundManager.canPlayURL(url), true, "Plain URL w/ mp3 in the path", url);
url = "http://freshly-ground.com/misc/music/carl-3-barlp.mp4";
is(soundManager.canPlayURL(url), false, "MP4 file", url);
url = "http://freshly-ground.com/misc/mp3/carl-3-barlp.mp4";
is(soundManager.canPlayURL(url), false, "MP4 w/ mp3 in the path", url);
url = "http://freshly-ground.com/misc/music/carl-3-barlp.mp4?extension=mp3";
is(soundManager.canPlayURL(url), false, "MP4 w/ mp3 in the parameters", url);
}
function is(result, expected, message, url) {
var passed = (result == expected);
var rowElement = document.createElement('tr');
var resultElement = document.createElement('td');
var expectedElement = document.createElement('td');
var messageElement = document.createElement('td');
resultElement.className = passed ? "passed" : "failed";
resultElement.innerHTML = "[ " + resultElement.className.toUpperCase() + " ]";
expectedElement.innerHTML = expected;
messageElement.innerHTML = message;
rowElement.appendChild(resultElement);
rowElement.appendChild(expectedElement);
rowElement.appendChild(messageElement);
if (url) {
var urlElement = document.createElement('td');
urlElement.className = "url"
urlElement.innerHTML = url;
rowElement.appendChild(urlElement);
}
document.getElementById("testMessages").appendChild(rowElement);
}
soundManager.onload = function() {
runTests();
}
</script>
<style type="text/css" media="screen">
body {
font-family: Helvetica, Arial, "MS Trebuchet", sans-serif;
}
#testMessages {
border:1px solid #eee;
}
#testMessages .passed {
color: #009900;
width: 100px;
}
#testMessages .failed {
color: #ff0000;
width: 100px;
}
#testMessages .url {
font-size: small;
color: #999;
}
th {
border-bottom: 1px solid #eee;
}
</style>
</head>
<body>
<h1>Test for Patch: <a href="http://gist.github.com/35493">gist:35493</a></h1>
<h2>Results:</h2>
<table border="0" cellspacing="5" cellpadding="5" id="testMessages">
<tr>
<th>Result</th>
<th>Expected</th>
<th>Message</th>
<th>URL</th>
</tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment