본문으로 건너뛰기
Version: 5.3

그룹 음성 통화

그룹 음성 통화를 구현하는 예제 코드입니다.

필수 조건

시작하기 전에 다음 작업을 수행해야 합니다.

오디오 엘리먼트 구현

그룹 음성 통화에서 그룹 음성을 재생하기 위한 오디오 엘리먼트를 준비합니다.

<html>
<div>
<audio id="room-audio" autoplay></audio>
</div>
</html>

<script>
const roomAudioElement = document.getElementById('room-audio');
</script>

그룹 통화 입장

그룹 통화 생성과 설정을 위한 ConferenceParams 객체를 만듭니다.

const conferenceParams = {
myId: 'MY_ID',
myServiceId: 'MY_SERVICE_ID',
roomId: 'ROOM_ID',
roomServiceId: 'ROOM_SERVICE_ID',
accessToken: 'ACCESS_TOKEN',
mediaType: 'audio',
mediaHtmlElement: {
roomAudio: roomAudioElement
},
delegate: {
// For each of the following, add your own implementation or assign an event handler that matches the signature
evtConnected: () => {},
evtDisconnected: (disconnectedParam) => {}
}
};

ConferenceParams 객체를 인자로 joinConference()를 호출하세요. joinConference() 호출에 실패한 경우 아래 두 경우로 나눠 실패 원인을 확인할 수 있습니다.

  • 통화 연결 시도 시 실패하는 경우
    • Promise.reject()로 반환되는 JoinConferenceError에서 START_FAIL_REASON을 확인해 실패 원인을 파악할 수 있습니다.
  • 통화 연결 후 실패하는 경우
    • 통화 연결 후에는 ConferenceParams.delegateevtDisconnected 이벤트를 통해 실패 원인을 확인할 수 있습니다. 통화 종료 이유와 관련된 자세한 내용은 통화 종료 이유를 참고하세요.
planetKit.joinConference(conferenceParams)
.then(() => {
// Successfully joined a conference
})
.catch((joinConferenceError) => {
// Failed to join a conference
// joinConferenceError.reason: START_FAIL_REASON
// joinConferenceError.message: A descriptive message about the failure.
});

그룹 통화 퇴장

그룹 통화에서 퇴장하려면 leaveConference()를 호출하세요.

planetKit.leaveConference();

관련 예제 코드

관련 문서