tencent cloud

Game Multimedia Engine

릴리스 노트
제품 소개
제품 개요
장점 및 특징
제품 기능
응용 시나리오
보안 및 컴플라이언스 인증
사용자 튜토리얼
SDK 다운로드 가이드
제품 기능 데모
기본 기능 데모
시나리오 기반 Demo
콘솔 가이드
사용량 조회
서비스 활성화
시작하기
Quick Integration of SDK
Quick Integration of Sample Project
기본 기능 개발 가이드
인증 키
실시간 음성 채팅 역할 설정
음질 선택
고급 기능 개발 가이드
서버 녹음
레인지 보이스
3D 음향 효과
음향 효과 및 반주
네트워크 오디오 스트림 포워딩 라우팅
사용자 지정 메시지 채널
회사 방화벽 제한을 해결하는 방법
Language Parameter Reference List
GME 채팅방 관리 통합
클라이언트 API
Unity SDK
SDK for Unreal Engine
Cocos2D SDK
SDK for Windows
SDK for iOS
SDK for Android
SDK for macOS
H5 SDK
Electron SDK
SDK for Flutter
SDK Version Upgrade Guide
에러 코드
Toolchain
Server APIs
History
Introduction
API Category
Usage APIs
Recording APIs
Making API Requests
Voice Chat APIs
Application APIs
Data Types
Error Codes
FAQ
제품 기능
문제 해결 가이드
과금
Sample Project 사용 문제
일반 문제
인증
방 입장 실패
사운드 및 오디오
네트워크
음성을 텍스트로 변환
프로그램 내보내기
Service Agreement
Service Level Agreement
문의하기
용어집
GME 정책
데이터 처리 및 보안 계약
개인 정보 보호 정책

API Documentation

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-01-18 15:13:51
Note:
Only some GME features are supported by the SDK for HTML5. Please refer to this document for the supported APIs and evaluate whether the SDK for HTML5 is appropriate for your business scenario.
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
Note:
After a GME API is called successfully, QAVError.OK will be returned with the value being 0.
Authentication is required for room entry in GME. For more information, see the authentication section in relevant documentation.
Operation on devices should be performed after successful room entry.
Starting from Chrome 74, navigator.mediaDevices can only be used in an HTTPS environment; therefore, please use HTTPS.

Integrating JQ

You need to integrate JQ to use the demo.
<!--Step 2: Add the audio container-->
<!--Container, which is used to carry audio tags and cannot be omitted.-->
<div id="gme-audio-wrap"></div>

Initialization APIs

Before initialization, the SDK is in the uninitialized state. A room can be entered only after the initialization authentication is performed and the SDK is initialized.

Initializing the SDK

For more information on how to get parameters, see Access Guide. This API requires the 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).
Note:
The SDK must be initialized before a user can enter a room.

Function prototype

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.

Sample code

const cSdkAppId = () => document.getElementById("input-SdkAppId").value;
const cOpenID = () => document.getElementById("input-OpenID").value;
gmeAPI.Init(document, cSdkAppId(), cOpenID());

Setting callbacks

The API class uses the 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.

Function prototype

WebGMEAPI.fn.SetTMGDelegate = function (delegate){...}
Parameter
Description
onEvent
SDK callback event

Sample code

gmeAPI.SetTMGDelegate(onEvent);

Voice Chat APIs

You should initialize and call the SDK to enter a room before voice chat can start.

Entering a room

When a user enters a room with the generated authentication information, the 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.

Function prototype

WebGMEAPI.fn.EnterRoom = function (roomId, roomType, authBuffer) {...}
Parameter
Description
roomId
Room ID, which can contain up to 127 characters
roomType
Room audio type
authBuffer
Authentication key. For more information on how to get it, see Project Configuration.

Sample code

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 successfully
if (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);
}
});
});

Event Callbacks

After the user enters the room, the message ITMG_MAIN_EVENT_TYPE_ENTER_ROOM will be sent and identified in the OnEvent function.

Sample code

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 below
app._data.brSend = result.UploadBRSend;// Bitrate of the uploaded audio data
app._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
}
};
The received peer information is as follows (downStreamInfoList):
Parameter
Description
brRecv
The received bitrate
delay
Receipt delay
jitterBufferMs
Delay caused by jitter
jitterReceived
The received Jitter

Exiting a room

This API is called to exit the current room. It is an async API. There will be a callback after room exit. The returned value of AV_OK indicates a successful async delivery.

Function prototype

WebGMEAPI.fn.ExitRoom = function (){...}

Sample code

gmeAPI.ExitRoom();

Turning on/off the mic

This API is used to turn on/off the mic. Mic and speaker are not turned on by default after room entry.

Function prototype

WebGMEAPI.fn.EnableMic = function (bEnable) {...}
Parameter
Description
isEnabled
To turn on the mic, set this parameter to true; otherwise, set it to false.

Sample code

gmeAPI.EnableMic(false);

Setting the mic volume

This API is used to set the mic volume. The corresponding parameter is volume. 0 indicates that the audio is mute, while 100 indicates that the volume remains unchanged. The default value is 100.

Function prototype

WebGMEAPI.fn.SetMicVolume = function (volume){...}
Parameter
Description
volume
Sets the volume. Value range: 0-100.

Sample code

gmeAPI.SetMicVolume(100);

Turning on/off the speaker

This API is used to turn on/off the speaker.

Function prototype

WebGMEAPI.fn.EnableSpeaker = function (bEnable){...}
Parameter
Description
isEnabled
To turn off the speaker, set this parameter to false; otherwise, set it to true.

Sample code

gmeAPI.EnableSpeaker(true);


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백