From ea488f180abcf375e4494cb19eb4c910d61d7bb8 Mon Sep 17 00:00:00 2001 From: Brian Chirls Date: Tue, 23 Jul 2019 16:52:01 -0400 Subject: [PATCH] Add "Import File Example" --- examples/import-file/import.js | 34 +++++++++++ examples/import-file/index.html | 102 ++++++++++++++++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 examples/import-file/import.js create mode 100644 examples/import-file/index.html diff --git a/examples/import-file/import.js b/examples/import-file/import.js new file mode 100644 index 0000000..5305ad2 --- /dev/null +++ b/examples/import-file/import.js @@ -0,0 +1,34 @@ +(function () { + var url = null; + + function handleFile(evt) { + // var reader = new FileReader; + var files = evt.dataTransfer && evt.dataTransfer.files || evt.target && evt.target.files; + var file = files && files.length && files[0]; + var medium = file && file.type.split('/')[0]; + + var ambisonicElement = document.getElementById('ambisonic'); + var ambisonic = ambisonicElement.components.ambisonic; + + evt.preventDefault(); + + if (medium === 'video' || medium === 'audio') { + ambisonic.pauseSound(); + if (url) { + URL.revokeObjectURL(url); + } + url = URL.createObjectURL(file); + ambisonicElement.setAttribute('src', url); + ambisonic.playSound(); + } + return false; + } + + window.addEventListener('dragover', function (evt) { + evt.preventDefault(); + return false; + }); + window.addEventListener('drop', handleFile, true); + + document.getElementById('import-file').addEventListener('change', handleFile, false); +}()); \ No newline at end of file diff --git a/examples/import-file/index.html b/examples/import-file/index.html new file mode 100644 index 0000000..fcce603 --- /dev/null +++ b/examples/import-file/index.html @@ -0,0 +1,102 @@ + + + + + Import Ambisonic Audio File | A-Frame Ambisonic Audio Component + + + + + + + + + + + + + + + + + + + + + + + +
+
+

Import 4-channel ambisonic audio file from device.

+ + +
+ Aframe Environment Component +
+ + + + + +