1,295
edits
Line 143: | Line 143: | ||
1) Play video with processing effect applied to the audio track | 1) Play video with processing effect applied to the audio track | ||
<video src="foo.webm" id="v" controls | <video src="foo.webm" id="v" controls></video> | ||
<audio id="out" autoplay></audio> | <audio id="out" autoplay></audio> | ||
<script> | <script> | ||
document.getElementById("out").src = | document.getElementById("out").src = | ||
document.getElementById("v"). | document.getElementById("v").captureStream().createProcessor(new Worker("effect.js")); | ||
</script> | </script> | ||
2) Play video with processing effects mixing in out-of-band audio tracks (in sync) | 2) Play video with processing effects mixing in out-of-band audio tracks (in sync) | ||
<video src="foo.webm" id="v" | <video src="foo.webm" id="v"></video> | ||
<audio src="back.webm" id="back"></audio> | <audio src="back.webm" id="back"></audio> | ||
<audio id="out" autoplay></audio> | <audio id="out" autoplay></audio> | ||
<script> | <script> | ||
var mixer = document.getElementById("v"). | var mixer = document.getElementById("v").captureStream().createProcessor(new Worker("audio-ducking.js")); | ||
mixer.addStream(document.getElementById("back"). | mixer.addStream(document.getElementById("back").captureStream()); | ||
document.getElementById("out").src = mixer; | document.getElementById("out").src = mixer; | ||
function startPlaying() { | function startPlaying() { | ||
Line 283: | Line 283: | ||
var audio = new Audio(src); | var audio = new Audio(src); | ||
audio.oncanplaythrough = new function() { | audio.oncanplaythrough = new function() { | ||
var stream = audio. | var stream = audio.captureStream(); | ||
stream.live = true; | stream.live = true; | ||
effectsMixer.addStream(stream); | |||
stream.onended = function() { effectsMixer.removeStream(stream); } | stream.onended = function() { effectsMixer.removeStream(stream); } | ||
audio.play(); | |||
} | } | ||
} | } |
edits