API | Description |
Init | Initializes API |
SetTMGDelegate | Sets delegation |
EnterRoom | Enters audio room |
EnableMic | Turns on/off the capturing device |
EnableSpeaker | Turns on/off the playback device |
SetMicVolume | Sets mic volume |
ExitRoom | Exits audio room |
QAVError.OK
will be returned with the value being 0.navigator.mediaDevices
can only be used in an HTTPS environment; therefore, please use HTTPS.<!--Step 2: Add the audio container--><!--Container, which is used to carry audio tags and cannot be omitted.--><div id="gme-audio-wrap"></div>
SDKAppID
from the Tencent Cloud console and the openId
as parameters. The openId
uniquely identifies a user with the rules stipulated by the application developer and must be unique in the application (currently, only INT64 is supported).WebGMEAPI.fn.Init = function (document, SdkAppId, openId) {...}
Parameter | Description |
document | HTML DOM Document object |
SdkAppId | SdkAppId from the Tencent Cloud console |
openId | Developer-defined user account with a value greater than 10,000, which is used to identify the user. |
const cSdkAppId = () => document.getElementById("input-SdkAppId").value;const cOpenID = () => document.getElementById("input-OpenID").value;gmeAPI.Init(document, cSdkAppId(), cOpenID());
Delegate
method to send callback notifications to the application. Register the callback function to the SDK to receive callback messages. The callback function should be registered to the SDK before room entry.WebGMEAPI.fn.SetTMGDelegate = function (delegate){...}
Parameter | Description |
onEvent | SDK callback event |
gmeAPI.SetTMGDelegate(onEvent);
ITMG_MAIN_EVENT_TYPE_ENTER_ROOM
message will be received as a callback. Mic and speaker are not turned on by default after room entry.WebGMEAPI.fn.EnterRoom = function (roomId, roomType, authBuffer) {...}
Parameter | Description |
roomId | Room ID, which can contain up to 127 characters |
roomType | Room audio type |
authBuffer |
function bindButtonEvents() {$("#start_btn").click(function () {console.log('start!');// Step 1: Get the `AuthBuffer`var FetchSigCgi = 'http://134.175.146.244:10005/';$.ajax({type: "POST",url: FetchSigCgi,dataType: 'json',data: {sdkappid: cSdkAppId(),roomid: cRoomNum(),openid: cOpenID(),},success: function (json) {// Step 2: `AuthBuffer` is obtained successfullyif (json && json.errorCode === 0) {let userSig = json.userSig;gmeAPI.Init(document, cSdkAppId(), cOpenID());gmeAPI.SetTMGDelegate(onEvent);gmeAPI.EnterRoom(cRoomNum(), 1, userSig);} else {console.error(json);}},error: function (err) {console.error(err);}});});
ITMG_MAIN_EVENT_TYPE_ENTER_ROOM
will be sent and identified in the OnEvent
function.onEvent = function (eventType, result) {if (eventType === gmeAPI.event.ITMG_MAIN_EVENT_TYPE_ENTER_ROOM){// Entered room successfully}else if (eventType === gmeAPI.event.ITMG_MAIN_EVENT_TYPE_USER_UPDATE){app._data.downStreamInfoList = result.PeerInfo;// Received peer information. For more information, see the table belowapp._data.brSend = result.UploadBRSend;// Bitrate of the uploaded audio dataapp._data.rtt = result.UploadRTT;// Upload RTT}else if (eventType === gmeAPI.event.ITMG_MAIN_EVENT_TYPE_EXIT_ROOM){// Exited room successfully}else if (eventType === gmeAPI.event.ITMG_MAIN_EVENT_TYPE_ROOM_DISCONNECT){// Room disconnected}};
Parameter | Description |
brRecv | The received bitrate |
delay | Receipt delay |
jitterBufferMs | Delay caused by jitter |
jitterReceived | The received Jitter |
AV_OK
indicates a successful async delivery.WebGMEAPI.fn.ExitRoom = function (){...}
gmeAPI.ExitRoom();
WebGMEAPI.fn.EnableMic = function (bEnable) {...}
Parameter | Description |
isEnabled | To turn on the mic, set this parameter to true ; otherwise, set it to false . |
gmeAPI.EnableMic(false);
volume
. 0 indicates that the audio is mute, while 100 indicates that the volume remains unchanged. The default value is 100.WebGMEAPI.fn.SetMicVolume = function (volume){...}
Parameter | Description |
volume | Sets the volume. Value range: 0-100. |
gmeAPI.SetMicVolume(100);
WebGMEAPI.fn.EnableSpeaker = function (bEnable){...}
Parameter | Description |
isEnabled | To turn off the speaker, set this parameter to false ; otherwise, set it to true . |
gmeAPI.EnableSpeaker(true);
この記事はお役に立ちましたか?