제품 개요
하위 제품 소개
기본 개념
제품 기능
응용 시나리오
제품 장점
사용 제한

<script src="https://video.sdk.qcloudecdn.com/web/TXLivePusher-2.1.0.min.js" charset="utf-8"></script>
<div id="id_local_video" style="width:100%;height:500px;display:flex;align-items:center;justify-content:center;"></div>
var livePusher = new TXLivePusher();
livePusher.setRenderView('id_local_video');
document.getElementById('id_local_video').getElementsByTagName('video')[0].muted = true;
// 비디오 품질 설정livePusher.setVideoQuality('720p');// 오디오 품질 설정livePusher.setAudioQuality('standard');// 프레임 레이트 사용자 정의livePusher.setProperty('setVideoFPS', 25);
// 카메라 켜기livePusher.startCamera();// 마이크 켜기livePusher.startMicrophone();
rtmp://를 webrtc://로 바꾸면 됩니다.livePusher.startPush('webrtc://domain/AppName/StreamName?txSecret=xxx&txTime=xxx');
var hasVideo = false;var hasAudio = false;var isPush = false;livePusher.setObserver({onCaptureFirstAudioFrame: function() {hasAudio = true;if (hasVideo && !isPush) {isPush = true;livePusher.startPush('webrtc://domain/AppName/StreamName?txSecret=xxx&txTime=xxx');}},onCaptureFirstVideoFrame: function() {hasVideo = true;if (hasAudio && !isPush) {isPush = true;livePusher.startPush('webrtc://domain/AppName/StreamName?txSecret=xxx&txTime=xxx');}}});
livePusher.stopPush();
// 카메라 끄기livePusher.stopCamera();// 마이크 끄기livePusher.stopMicrophone();
TXLivePusher.checkSupport().then(function(data) { // WebRTC 지원 여부 if (data.isWebRTCSupported) { console.log('WebRTC Support'); } else { console.log('WebRTC Not Support'); } // H264 인코딩 지원 여부 if (data.isH264EncodeSupported) { console.log('H264 Encode Support'); } else { console.log('H264 Encode Not Support'); }});
livePusher.setObserver({ // 푸시 스트리밍 경고 메시지 onWarning: function(code, msg) { console.log(code, msg); }, // 푸시 스트리밍 연결 상태 onPushStatusUpdate: function(status, msg) { console.log(status, msg); }, // 푸시 스트리밍 통계 데이터 onStatisticsUpdate: function(data) { console.log('video fps is ' + data.video.framesPerSecond); }});
var deviceManager = livePusher.getDeviceManager();// 디바이스 리스트 가져오기deviceManager.getDevicesList().then(function(data) { data.forEach(function(device) { console.log(device.deviceId, device.deviceName); });});// 카메라 디바이스 전환deviceManager.switchCamera('camera_device_id');
피드백