Giter Club home page Giter Club logo

Comments (15)

fabslab avatar fabslab commented on June 23, 2024 1

Voila, WebSocket streaming in a branch on my fork ->
https://github.com/fsbdev/aurora.js/blob/WebSocket-Source/src/sources/browser/websocket.coffee

If this would be accepted into the main repo, let me know. Feedback is welcome.

The corresponding server implementation you'll need to run it, for Node.js, is here ->
https://gist.github.com/fsbdev/6277584

from aurora.js.

comster avatar comster commented on June 23, 2024

I've spent a good amount of time using the Aurora and browser media requests against my node.js server (and mongodb gridfs files).

Straightening out my HTTP 206, and HEAD requests helped me get it working. I forget exactly how it reacted to each of my responses, but I eventually ended up with this, which might help you:
https://github.com/comster/house/blob/master/lib/endPoints/files/index.js#L105

Let me know if that helps.

from aurora.js.

devongovett avatar devongovett commented on June 23, 2024

Make sure you're serving Aurora from the same server you're serving media from, or provide CORS headers for the media files otherwise it won't be able to make cross domain requests. The HEAD request is necessary to get the file size headers (make sure you're serving those too) for the file so that it can download the file in chunks rather than waiting until the entire thing is downloaded before playback begins. Let me know if you figure it out!

from aurora.js.

mhuusko5 avatar mhuusko5 commented on June 23, 2024

comster that's exactly what i'm looking for

it kind of brings up a new issue though... what my node.js server actually does is grab video, strip out the audio, and server up that audio, all on the fly
so when that HEAD request comes in, it is impossible for the node.js server to know what the side of the audio file will be

before when i was just using an html5 audio element, i just left it as chunked encoding, gave no content-length, and everything was fine
can Aurora work this way too, or might there be a workaround?

thanks

from aurora.js.

mpilone avatar mpilone commented on June 23, 2024

I'm having the same issue here. My server side converts some audio files on the fly and streams back using chunked encoding (http://en.wikipedia.org/wiki/Chunked_transfer_encoding). It seems like I would need to convert the file in the head request and cache it so I can return a valid file size but that kills end user performance because I can't stream the audio as it is converted.

from aurora.js.

devongovett avatar devongovett commented on June 23, 2024

The problem is that browsers don't offer a streaming XMLHttpRequest API, so we're forced to make a single head request to get the total file size, followed by many small range requests in order to simulate streaming. If you're serving up files on the fly, they probably won't accept returning ranges and/or will cause your server to regenerate the audio data. So, unfortunately, until browsers add a streaming API that we can make use of (basically support for chunked binary XHR), we can't do much if anything about it. The only solution as far as I can see is to basically cache the converted audio files on your server when the HEAD request comes in, and serve that file allowing range requests from then on...

from aurora.js.

fabslab avatar fabslab commented on June 23, 2024

This indicates a good future: http://www.w3.org/TR/streams-api/ :)

from aurora.js.

mscdex avatar mscdex commented on June 23, 2024

What about streaming via websockets?

from aurora.js.

fabslab avatar fabslab commented on June 23, 2024

Aurora.js doesn't include that currently so I've just started working on a solution for it. The documentation for Aurora.js could use a lot of improvement though, it's been a bit slow to get an understanding of all the code.

from aurora.js.

fabslab avatar fabslab commented on June 23, 2024

I've now turned the code into a plugin:
https://github.com/fsbdev/aurora-websocket

from aurora.js.

rodhoward avatar rodhoward commented on June 23, 2024

Hi fsbdev,

I have got your websocket plugin to work!! Thanks! I can now stream audio from mp3 files over the websocket and play them using the aurora mp3.js codec.

However what I can't seem to do is get it to work when streaming directly from ffmpeg from stdout using spawn child process. The first issue was the file size (for live streaming this is unknown) but that seems like its just for the progress bar so not a big deal just returned a large number. So bottom line I'm getting data into your plugin and it is emiting the data events no errors but also no sound.

Any Ideas would be more than welcome! Thanks again for a great contribution.

from aurora.js.

fabslab avatar fabslab commented on June 23, 2024

Yes the file size is optional. The issue is most likely with the mp3.js code. I've looked at an issue like this before where that was the case. You could try your luck with one of the other codec files like flac.js.

from aurora.js.

pafnat avatar pafnat commented on June 23, 2024

any progress?

from aurora.js.

MidnightJava avatar MidnightJava commented on June 23, 2024

fsbdev, I'm using your plugin and the vorbis codec to stream vorbis-encoded data from a software defined radio implementation into my client. It works for a while and then stops. I have to reload the web app page to get it working again. It cuts out after a variable amount of time, anywhere from a few seconds to 45 or 50 seconds.

The same WebSocketServer doesn't cut out when used with a different client implementation, which pulls the data from each call to the listener, and dumps it into an Audio buffer in a WebAudio player implementation. That doesn't stop playing, but it has drop-outs every few seconds, which is why I'm trying to use your WebSocket plugin.

We probably have something wrong in our WebSocketServer. Can you think of anything that we might be doing that would cause the WebSocket plugin to drop the connection and stop playing the audio?

from aurora.js.

revolunet avatar revolunet commented on June 23, 2024

Here's a cool related demo that use the new fetch browser API to stream the remote file, https://jakearchibald.com/2015/thats-so-fetch

from aurora.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.