Prototyping 19 November 2012: Difference between revisions
Line 23: | Line 23: | ||
==random play audio code == | ==random play audio code == | ||
the html (put inside the body tag of an html page) | |||
<source lang="html4strict"> | <source lang="html4strict"> | ||
<audio controls onpause="onpause()" ondurationchange="jump ()" src = "http://wsdownload.bbc.co.uk/worldservice/css/96mp3/latest/bbcnewssummary.mp3"></audio> | <audio controls onpause="onpause()" ondurationchange="jump ()" src = "http://wsdownload.bbc.co.uk/worldservice/css/96mp3/latest/bbcnewssummary.mp3"></audio> | ||
</source> | </source> | ||
You can put the script at the end of the page (after the audio tag!): | |||
<source lang="javascript"> | <source lang="javascript"> | ||
<script> | <script> |
Revision as of 23:24, 20 November 2012
The origin and theory of the cut-up, annotated audio, essay on ubuweb.
Shuffle
Javascript doesn't include a built-in function to shuffle an array, but there are lots of "recipes" to do it.
For instance: http://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array-in-javascript
var shuffle = function (o) {
for (var j,x,i=o.length; i; j=parseInt(Math.random()*i), x=o[--i], o[i] = o[j], o[j] = x);
return o;
}
Audio cut-up
The BBC World Service produces and releases an hourly "headlines" recording
- Audio feed (high quality)
- HTML5 media events (timeupdate, durationchange, seeked)
- Live demo of HTML5 player events
- HTML5 media events
random play audio code
the html (put inside the body tag of an html page)
<audio controls onpause="onpause()" ondurationchange="jump ()" src = "http://wsdownload.bbc.co.uk/worldservice/css/96mp3/latest/bbcnewssummary.mp3"></audio>
You can put the script at the end of the page (after the audio tag!):
<script>
var a = document.getElementsByTagName('audio')[0]
var id
function jump (){
//var a = document.getElementsByTagName('audio')[0]
a.currentTime=Math.random()*a.duration
a.play()
id=setTimeout(jump,3000)
}
function onpause (){
clearTimeout(id)
}
</script>