AgoraIO-Community / AgoraWebSDK-NG

The Next Generation of Agora Web SDK
https://agoraio-community.github.io/AgoraWebSDK-NG/
161 stars 75 forks source link

Feature request, provide access to remote audio MediaStream object #124

Closed homanchou closed 3 years ago

homanchou commented 3 years ago

Describe the bug

Agora WebSDK-NG does not include spatial audio out of the box. That's ok, 3D libraries such as Babylon.js do support spatial audio that can attach a MediaStream to a 3D mesh, https://github.com/BabylonJS/Babylon.js/blob/master/src/Audio/sound.ts#L215

The problem is, the Agora API on "user-published" only provides the remote audio as an interface IRemoteAudioTrack.

Is there a way to get at the underlying MediaStream so I can pass it to Babylon.js?

Platform and Browser:

Web/Chrome

SDK Version:

"agora-rtc-sdk-ng": "^4.1.0"

HAHAHA44 commented 3 years ago

You can call getUserMedia to get the MediaStream and handle it by yourself, then use createCustomAudioTrack interface to create AgoraTrack with your MediaStreamTrack.