WebAudio / web-audio-api

The Web Audio API v1.0, developed by the W3C Audio WG
https://webaudio.github.io/web-audio-api/
Other
1.06k stars 168 forks source link

MediaElementSourceNode should have one output per track on media elements with multiple tracks #352

Closed cwilso closed 8 years ago

cwilso commented 10 years ago

Reported to HTML (https://www.w3.org/Bugs/Public/show_bug.cgi?id=26534), but this is really a requirement on how we create MediaElementSourceNodes.

Change MediaElementSource definition in Web Audio to create one output per track on the media element node, rather than a single output.

adorn commented 10 years ago

I reported the initial issure at w3.org.

Use Case

We have some mpeg4 Proxy-Files from a professional video-camera with four stereo audiotracks. Our webapp should make it possible to playback all the tracks at the same time, and mix them (volume/panning).

Proposed solution1

var mediaElement = document.getElementById('mediaElementID');

// May use a more sophisticated logic to find the right Track, // f.e. dependindung on audioTrack.language oder audioTrack.kind var audioTrack1 = mediaElement .audioTracks[0];
var trackId1 = audioTrack1.id;

var sourceNode1 = context.createMediaElementSource(mediaElement,trackId1); var sourceNode2 = context.createMediaElementSource(mediaElement,mediaElement .audioTracks[1]) ....

Proposed solution2

var mediaElement = document.getElementById('mediaElementID'); var audioTrack1 = mediaElement .audioTracks[0];

var sourceNode1 = context.createMediaElementSource(audioTrack1 ); var sourceNode2 = context.createMediaElementSource( mediaElement .audioTracks[2]); ...

padenot commented 8 years ago

This will be implemented with MediaStreams in #264.

You can do HTMLMediaElement.captureStream(). This returns a MediaStream with multiple tracks (on per AudioTrack). You can then create route those tracks into Web Audio using the new MediaStreamTrackAudioSourceNode, and process the tracks as needed.

Closing this one, as #264 has a pull-request already in flight.