Comments (4)
Here's the images from my console dump...
from aurora.js.
Same here. Though I am not using websockets but xhr to get chunks, I pretty much followed the same trail.
<script type="text/javascript" src="exjs/aurora/aurora.js"></script>
<script type="text/javascript" src="exjs/aurora/mp3.js"></script>
var aurora_source = null;
/* Chunk is a part of an MP3 */
while(1)
{
chunk = loadAChunk();
makeNoise(Chunk);
}
function makeNoise(chunk)
{
var uarr = makeUint8Array(chunk);
var abData = new AV.Buffer(uarr);
if (!aurora_source) {
var MySource = AV.EventEmitter.extend ({
start: function() {
console.log("start data");
this.emit('data',abData);
},
pause: function() {
// nope
},
reset: function() {
// nope
}
});
aurora_source = new MySource();
asset = new AV.Asset(aurora_source);
player = new AV.Player(asset);
player.play();
} else {
aurora_source.emit('data',abData);
}
Result: No audio but an error: ailed to load script: blob:6d445111-e01a-4701-90ef-351bf8689348 (nsresult = 0x805e0006)
The corresponding code in aurora.js:
url = AV.Buffer.makeBlobURL("setInterval(function() { postMessage('ping'); }, " + interval + ");");
if (url == null) {
return setInterval(fn, interval);
}
worker = new Worker(url);
from aurora.js.
after some testing, I figured out that it actually works but not with all files, ABR and CBR with rate more then 64k isnt playing while buffering, after buffering is complite and if call play() song will play.
VBR situation is better, works with good quality on 441000 sampling, 48000 the situation same as CBR.
also for some reason player isnt working on iOS safari/chrome, buffering going well, but no playback.
with android - almost the same, only firefox on android able to play it but with big delay and UI getting slow while playing song.
here is server side
var audioFolder = __dirname + '/audio/';
wss.on('connection', function(ws) {
var audioPath, audioStream, createFileStream;
audioStream = null;
audioPath = audioFolder + '10.mp3';
fs.stat(audioPath, function(err, stats) {
if (err) {
return ws.send(JSON.stringify({error: 'Could not retrieve file.'}));
} else {
ws.send(JSON.stringify({
fileSize: stats.size
}));
return createFileStream();
}
});
var createFileStream = function() {
audioStream = fs.createReadStream(audioPath);
audioStream.on('data', function(data) {
ws.send(data, {binary: true});
});
audioStream.on('end', function() {
ws.send(JSON.stringify({end: true}));
});
};
});
and the client-side
var host = window.document.location.host.replace(/:.*/, '');
var AudioSource = AV.EventEmitter.extend ({
start: function() {
var source = this;
source.bytesLoaded = 0;
var ws = new WebSocket('ws://' + host + ':3000');
ws.binaryType = "arraybuffer";
ws.onmessage = function (event) {
var data = event.data;
if ("string" != typeof data) {
data = new AV.Buffer(new Uint8Array(data));
source.bytesLoaded += data.length;
if (data) {
source.emit("progress", 100 * (source.bytesLoaded / source.length));
}
source.emit("data", data);
} else {
data = JSON.parse(data);
if (null != data.fileSize) {
source.length = data.fileSize;
} else if (null != data.error) {
source.emit("error", data.error);
} else if (data.end) {
source.emit("end");
} else {
return;
}
}
};
},
pause: function() {},
reset: function() {},
});
var buffer = new AudioSource();
var asset = new AV.Asset(buffer);
var player = new AV.Player(asset);
player.play();
from aurora.js.
Closing due to inactivity.
from aurora.js.
Related Issues (20)
- How do I decode to raw, resample to 44,1khz and split stereo into dual mono buffers?
- "Something is wrong in HTTPSource.loop" while using AV.Asset.fromURL(remoteUrl)
- [Solved]switch backend from Speaker to PortAudio(naudiodon)
- Aurora not playing certain flac files with no error
- Live decoding on Android
- Node example HOT 1
- No default jsDelivr CDN file set
- Problems with 24-bit WAV files
- Questions about memory manage.
- Is decoding a specific part of a gargantuan file supported efficiently? HOT 3
- HTTP requests still sending to server even if HTTP error is returned
- Unit tests fail on master branch
- Chrome browser change for same site cookies
- gyp build fail HOT 1
- build for browser
- m4a demuxer fails when processing a file with co64 atom
- Window Not Defined
- decode fail
- How to install additional codecs? HOT 1
- Uncaught SyntaxError: Unexpected identifier 'key'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aurora.js.