diff --git a/examples/index.html b/examples/index.html
index ba43af7..c53f07b 100755
--- a/examples/index.html
+++ b/examples/index.html
@@ -18,6 +18,8 @@
A-Frame Ambisonic Audio Component
Higher Order Ambisonics
+ Import file
+
diff --git a/src/ambisonic-audio.js b/src/ambisonic-audio.js
index e0bc783..2aa2754 100644
--- a/src/ambisonic-audio.js
+++ b/src/ambisonic-audio.js
@@ -192,8 +192,8 @@ AFRAME.registerComponent('ambisonic', {
if (src instanceof window.HTMLMediaElement) {
newMediaElement = src;
this.ownMediaElement = false;
- } else {
- newMediaElement = this.mediaElement || document.createElement('audio');
+ } else if (src) {
+ newMediaElement = document.createElement('audio');
newMediaElement.src = src;
// this.mediaElement.load();
this.ownMediaElement = true;
@@ -219,7 +219,11 @@ AFRAME.registerComponent('ambisonic', {
}
this.mediaElement = newMediaElement;
this.audioSources = [];
- this.audio.setMediaElementSource(this.mediaElement);
+ if (this.mediaElement) {
+ this.audio.setMediaElementSource(this.mediaElement);
+ } else if (this.audio.source) {
+ this.audio.disconnect();
+ }
} else {
// load audio buffer