|
@@ -33,7 +33,7 @@ export const AUDIO_DEVICE_VOLUME = 'audio-device-volume'
|
|
|
|
|
|
const runtime = reactive({
|
|
|
/** 房间id */
|
|
|
- roomUid: 'LIVE-2112263-12345',
|
|
|
+ roomUid: sessionStorage.getItem('roomUid') || '',
|
|
|
/** IM连接状态 */
|
|
|
imConnectStatus: 'connecting' as imConnectStatus,
|
|
|
// 屏幕分享状态
|
|
@@ -385,13 +385,14 @@ export const startLive = async (resetTime = true) => {
|
|
|
if (room) {
|
|
|
// const microphoneAudioTrack = await getTrack('microphone')
|
|
|
// const cameraVideoTrack = await getTrack('camera')
|
|
|
- // await setTrack([cameraVideoTrack], 'camera')
|
|
|
- // await setTrack([microphoneAudioTrack], 'microphone')
|
|
|
+ await setTrack([runtime.activeTracks.camera as RTC.RCLocalVideoTrack], 'camera')
|
|
|
+ await setTrack([runtime.activeTracks.microphone as RTC.RCLocalAudioTrack], 'microphone')
|
|
|
// const builder = await runtime.joinedRoom?.getMCUConfigBuilder()
|
|
|
// // @ts-ignore
|
|
|
// await builder.setOutputVideoRenderMode?.(RTC.MixVideoRenderMode.WHOLE)
|
|
|
// // @ts-ignore
|
|
|
// await builder.flush()
|
|
|
+ // console.log(runtime.activeTracks)
|
|
|
await request.get('/api-web/imLiveBroadcastRoom/opsLiveVideo', {
|
|
|
params: {
|
|
|
type: '1',
|
|
@@ -410,7 +411,7 @@ export const startLive = async (resetTime = true) => {
|
|
|
/**
|
|
|
* 关闭直播
|
|
|
*/
|
|
|
-export const closeLive = async () => {
|
|
|
+export const closeLive = async (remove = false) => {
|
|
|
// removeMedia(runtime.mediaStreams, runtime.mediaStreamTrack)
|
|
|
await request.get('/api-web/imLiveBroadcastRoom/opsLiveVideo', {
|
|
|
params: {
|
|
@@ -421,15 +422,19 @@ export const closeLive = async () => {
|
|
|
})
|
|
|
sessionStorage.removeItem(START_LIVE_TIME)
|
|
|
sessionStorage.removeItem(START_LIVE_STATUS)
|
|
|
- runtime.videoStatus = 'stream'
|
|
|
+ // 关闭房间仅移除推流即可
|
|
|
for (const key in runtime.activeTracks) {
|
|
|
if (Object.prototype.hasOwnProperty.call(runtime.activeTracks, key)) {
|
|
|
const track = runtime.activeTracks[key as TrackType] as RTC.RCLocalTrack
|
|
|
if (track) {
|
|
|
- removeTrack([track], key as TrackType)
|
|
|
+ await runtime.joinedRoom?.unpublish([track])
|
|
|
+ if (remove) {
|
|
|
+ await removeTrack([track], key as TrackType)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ runtime.videoStatus = 'stream'
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -537,7 +542,7 @@ export const toggleDevice = async (trackType: TrackType) => {
|
|
|
}
|
|
|
|
|
|
export const leaveIMRoom = async () => {
|
|
|
- await closeLive()
|
|
|
+ await closeLive(true)
|
|
|
if (runtime.joinedRoom) {
|
|
|
// @ts-ignore
|
|
|
await runtime.rtcClient?.leaveRoom(runtime.joinedRoom)
|