Use "Live Audio" stream in top right if running
Prevents duplicate audio sources
This commit is contained in:
+12
-1
@@ -4,7 +4,17 @@
|
|||||||
// UPDATE: there is a problem in chrome with starting audio context
|
// UPDATE: there is a problem in chrome with starting audio context
|
||||||
// before a user gesture. This fixes it.
|
// before a user gesture. This fixes it.
|
||||||
var started = null;
|
var started = null;
|
||||||
|
var player = null;
|
||||||
window.onload = function(){
|
window.onload = function(){
|
||||||
|
var audioelement = window.parent.document.getElementsByTagName("audio")[0];
|
||||||
|
if (typeof(audioelement) != 'undefined') {
|
||||||
|
|
||||||
|
document.getElementById('player').remove();
|
||||||
|
|
||||||
|
player = audioelement;
|
||||||
|
} else {
|
||||||
|
player = document.getElementById('player');
|
||||||
|
}
|
||||||
if (started) return;
|
if (started) return;
|
||||||
started = true;
|
started = true;
|
||||||
initialize();
|
initialize();
|
||||||
@@ -25,7 +35,7 @@ function initialize() {
|
|||||||
process();
|
process();
|
||||||
|
|
||||||
function process() {
|
function process() {
|
||||||
const SOURCE = ACTX.createMediaElementSource(document.getElementById('player'));
|
const SOURCE = ACTX.createMediaElementSource(player);
|
||||||
SOURCE.connect(ANALYSER);
|
SOURCE.connect(ANALYSER);
|
||||||
SOURCE.connect(ACTX.destination)
|
SOURCE.connect(ACTX.destination)
|
||||||
const DATA = new Uint8Array(ANALYSER.frequencyBinCount);
|
const DATA = new Uint8Array(ANALYSER.frequencyBinCount);
|
||||||
@@ -79,6 +89,7 @@ h1 {
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<audio style="display:none" controls="" crossorigin="anonymous" id='player' autoplay=""><source src="/stream"></audio>
|
<audio style="display:none" controls="" crossorigin="anonymous" id='player' autoplay=""><source src="/stream"></audio>
|
||||||
<h1>Loading...</h1>
|
<h1>Loading...</h1>
|
||||||
<canvas></canvas>
|
<canvas></canvas>
|
||||||
|
|||||||
Reference in New Issue
Block a user