Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with streaming audio from WebRTC #581

Open
ben-pr-p opened this issue Jul 29, 2016 · 11 comments · May be fixed by #1634
Open

Compatibility with streaming audio from WebRTC #581

ben-pr-p opened this issue Jul 29, 2016 · 11 comments · May be fixed by #1634
Milestone

Comments

@ben-pr-p
Copy link

Hello,

I'm interested in using Howler for a VR-ish web experience using WebRTC for audio transmission – does Howler accept mediastream src's and can it perform its transformations fast enough for real-time playback?

@goldfire goldfire added this to the Future milestone Aug 21, 2016
@goldfire
Copy link
Owner

There is no support for MediaStream right now, but I've marked it in the "future" milestone as it could make a good plugin. Performance shouldn't be an issue on the part of howler.

@dburongarcia
Copy link

Hi, any news about WebRTC support?

@ampeixoto
Copy link

Any news on this?

1 similar comment
@Blunderchips
Copy link

Any news on this?

@cybersupernova
Copy link

cybersupernova commented Jun 16, 2020

I assume howler will not supporting MediaStream any time soon

DmACKGL referenced this issue in manueljlz/gcphone Jul 21, 2020
@gruckionvit
Copy link

Can you give an example of how this is supposed to work?

@gruckionvit
Copy link

There is no support for MediaStream right now, but I've marked it in the "future" milestone as it could make a good plugin. Performance shouldn't be an issue on the part of howler.
can we get an update of when this will be available? Some coaching would be appreciated if you want me to do it.

@jzombie
Copy link

jzombie commented Oct 2, 2020

Apologies if this is the wrong thread.

Maybe someone will find it useful.


I figured out how to make this stream over WebRTC.

The secret is to start the audio timer (i.e. just attach it to a non-mounted audio node; see below).

Then, obviously, you need to publish the audio media stream tracks to the other peer(s).

Note: This is modified from example posted at: https://jsfiddle.net/chadananda/kvzrsx5t/84/

import { Howl, Howler } from "howler";

const audioURL =
"https://cdn.glitch.com/02dcea11-9bd2-4462-ac38-eeb6a5ad9530%2F331_full_beautiful-minds_0171_preview.mp3?1522829295082";

Howler.mute(false); // to initialize Howler internals
const streamOutput = Howler.ctx.createMediaStreamDestination();

// first disconnect
Howler.masterGain.disconnect();
// then reconnect to our new destination

// Howler.masterGain.connect(options.audioOutput) ??
Howler.masterGain.connect(streamOutput); // connect masterGain to destination

// Start the audio timer (note, this doesn't have to be mounted to the DOM)
const audioEl = document.createElement("audio");
audioEl.srcObject = streamOutput.stream;

// Note: html5 audio must be used for this to work
const sound = new Howl({ html5: false, src: audioURL });

const mediaStream = streamOutput.stream;

// Audio tracks
const audioMediaStreamTracks = mediaStream.getAudioTracks();

// ...
sound.play() // start the audio

@vkarpuram
Copy link

@jzombie Could you please elaborate on this? It looks like the code sample provided plays directly from audioURL

@jzombie
Copy link

jzombie commented Nov 13, 2020

@vkarpuram I'm using Howler to mix several audio sources (i.e. instrument samples) into a single channel and broadcast them to several participants over WebRTC, who don't necessarily have Howler running on their end (each participant being able to trigger instrument samples playing over that mixed channel).

Instantiating new Howler sounds and playing them automatically mixes them into the stream at this point, and no additional WebRTC negotiations are necessary to add / remove audio data this way (also have TTS servicing from Google mixed into the same channel [i.e. send request to Google / receive mp3 / add mp3 as Howler sound, and play it => all participants hear it]).

At the moment, when I got it working, I thought I had accomplished something pretty cool, but later realize it's probably not what this thread is about.

Maybe someone would still find it useful, regardless.

@haojie06
Copy link

haojie06 commented Nov 4, 2022

Hi, at the end of 2022, is there any progress in the support of webrtc?

@rafern rafern linked a pull request Dec 8, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants