新增功能
This commit is contained in:
+243
@@ -0,0 +1,243 @@
|
||||
import b, { translateTRTCStreamId as v } from "@tencentcloud/trtc-cloud-wx";
|
||||
export * from "@tencentcloud/trtc-cloud-wx";
|
||||
import { default as H } from "@tencentcloud/trtc-cloud-wx";
|
||||
import { resolveComponent as m, openBlock as h, createElementBlock as y, createVNode as g, createBlock as _, createCommentVNode as C } from "vue";
|
||||
const f = (t, o) => {
|
||||
const r = t.__vccOpts || t;
|
||||
for (const [n, e] of o)
|
||||
r[n] = e;
|
||||
return r;
|
||||
}, p = b.getTRTCShareInstance(), u = p.trtc, l = p.InterfaceEventEmitter, R = {
|
||||
name: "TRTCPusher",
|
||||
data() {
|
||||
return {
|
||||
pusher: {},
|
||||
soundMode: ""
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
p.logger.info("trtc-pusher attached"), this.bindTRTCCloudEvent(), l.emit("pusherDomReady", !0);
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.executeCleanup();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.executeCleanup();
|
||||
},
|
||||
methods: {
|
||||
executeCleanup() {
|
||||
p.logger.info("trtc-pusher detached"), l.emit("pusherDomReady", !1), this.unbindTRTCCloudEvent(), p.exitRoom();
|
||||
},
|
||||
pusherAttributesChange(t) {
|
||||
const { pusher: o, callback: r } = t;
|
||||
this.pusher = { ...this.pusher, ...o }, r && this.$nextTick(r);
|
||||
},
|
||||
playerAudioRouteChange(t) {
|
||||
const { soundMode: o, callback: r } = t;
|
||||
this.soundMode = o, r && r();
|
||||
},
|
||||
bindTRTCCloudEvent() {
|
||||
l.on("pusherAttributesChange", this.pusherAttributesChange), l.on("playerAudioRouteChange", this.playerAudioRouteChange);
|
||||
},
|
||||
unbindTRTCCloudEvent() {
|
||||
l.off("pusherAttributesChange", this.pusherAttributesChange), l.off("playerAudioRouteChange", this.playerAudioRouteChange);
|
||||
},
|
||||
handleStateChange(t) {
|
||||
u.pusherEventHandler(t);
|
||||
},
|
||||
handleNetStatus(t) {
|
||||
u.pusherNetStatusHandler(t);
|
||||
},
|
||||
handleError(t) {
|
||||
u.pusherErrorHandler(t);
|
||||
},
|
||||
handleBGMStart(t) {
|
||||
u.pusherBGMStartHandler(t);
|
||||
},
|
||||
handleBGMProgress(t) {
|
||||
u.pusherBGMProgressHandler(t);
|
||||
},
|
||||
handleBGMComplete(t) {
|
||||
u.pusherBGMCompleteHandler(t);
|
||||
},
|
||||
handleAudioVolumeNotify(t) {
|
||||
p.isEnterRoom && u.pusherAudioVolumeNotify(t);
|
||||
}
|
||||
}
|
||||
}, I = { class: "trtc-pusher-container" };
|
||||
function A(t, o, r, n, e, a) {
|
||||
const d = m("live-pusher"), T = m("live-player");
|
||||
return h(), y("div", I, [
|
||||
g(d, {
|
||||
class: "trtc-pusher",
|
||||
url: e.pusher.url,
|
||||
mode: "HD",
|
||||
autopush: e.pusher.autopush,
|
||||
"enable-camera": e.pusher.enableCamera,
|
||||
"enable-mic": e.pusher.enableMic,
|
||||
muted: e.pusher.muted,
|
||||
"enable-agc": e.pusher.enableAgc,
|
||||
"enable-ans": e.pusher.enableAns,
|
||||
"enable-ear-monitor": e.pusher.enableEarMonitor,
|
||||
"auto-focus": e.pusher.enableAutoFocus,
|
||||
zoom: e.pusher.enableZoom,
|
||||
"min-bitrate": e.pusher.minBitrate,
|
||||
"max-bitrate": e.pusher.maxBitrate,
|
||||
"video-width": e.pusher.videoWidth,
|
||||
"video-height": e.pusher.videoHeight,
|
||||
beauty: e.pusher.beautyLevel,
|
||||
whiteness: e.pusher.whitenessLevel,
|
||||
orientation: e.pusher.videoOrientation,
|
||||
aspect: e.pusher.videoAspect,
|
||||
"device-position": e.pusher.frontCamera,
|
||||
"remote-mirror": e.pusher.enableRemoteMirror,
|
||||
"local-mirror": e.pusher.localMirror,
|
||||
"background-mute": e.pusher.enableBackgroundMute,
|
||||
"audio-quality": e.pusher.audioQuality,
|
||||
"audio-volume-type": e.pusher.audioVolumeType,
|
||||
"audio-reverb-type": e.pusher.audioReverbType,
|
||||
"waiting-image": e.pusher.waitingImage,
|
||||
"beauty-style": e.pusher.beautyStyle,
|
||||
fps: e.pusher.fps,
|
||||
filter: e.pusher.filter,
|
||||
onStatechange: a.handleStateChange,
|
||||
onNetstatus: a.handleNetStatus,
|
||||
onError: a.handleError,
|
||||
onBgmstart: a.handleBGMStart,
|
||||
onBgmprogress: a.handleBGMProgress,
|
||||
onBgmcomplete: a.handleBGMComplete,
|
||||
onAudiovolumenotify: a.handleAudioVolumeNotify
|
||||
}, null, 8, ["url", "autopush", "enable-camera", "enable-mic", "muted", "enable-agc", "enable-ans", "enable-ear-monitor", "auto-focus", "zoom", "min-bitrate", "max-bitrate", "video-width", "video-height", "beauty", "whiteness", "orientation", "aspect", "device-position", "remote-mirror", "local-mirror", "background-mute", "audio-quality", "audio-volume-type", "audio-reverb-type", "waiting-image", "beauty-style", "fps", "filter", "onStatechange", "onNetstatus", "onError", "onBgmstart", "onBgmprogress", "onBgmcomplete", "onAudiovolumenotify"]),
|
||||
g(T, {
|
||||
class: "trtc-player",
|
||||
"sound-mode": e.soundMode
|
||||
}, null, 8, ["sound-mode"])
|
||||
]);
|
||||
}
|
||||
const S = /* @__PURE__ */ f(R, [["render", A], ["__scopeId", "data-v-c40920dd"]]);
|
||||
const s = b.getTRTCShareInstance(), c = s.trtc, i = s.InterfaceEventEmitter, E = {
|
||||
name: "TRTCPlayer",
|
||||
props: {
|
||||
streamId: {
|
||||
type: String,
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
player: {},
|
||||
TRTCStreamId: "",
|
||||
soundMode: ""
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
streamId(t) {
|
||||
this.setTRTCStreamId(t);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
s.logger.info("trtc-player attached", this.streamId), this.streamId && i.emit("playerDomReady", { isReady: !0, view: this.streamId }), this.TRTCStreamId = this.getTRTCStreamId(this.streamId), this.bindTRTCCloudEvent();
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.executeCleanup();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.executeCleanup();
|
||||
},
|
||||
methods: {
|
||||
executeCleanup() {
|
||||
s.logger.info("trtc-player detached", this.streamId), i.emit("playerDomReady", { isReady: !1, streamId: this.streamId }), this.unbindTRTCCloudEvent();
|
||||
},
|
||||
setTRTCStreamId(t) {
|
||||
return s.logger.info("trtc-player setTRTCStreamId", t), new Promise((o, r) => {
|
||||
try {
|
||||
this.$emit("update:streamId", t), this.TRTCStreamId = this.getTRTCStreamId(t), this.$nextTick(() => {
|
||||
s.logger.info("trtc-player setTRTCStreamId success", t), o(), i.emit("playerDomReady", { isReady: !0, view: t });
|
||||
});
|
||||
} catch (n) {
|
||||
s.logger.info("trtc-player setTRTCStreamId fail", t, n), r(n);
|
||||
}
|
||||
});
|
||||
},
|
||||
// 其他方法保持原有逻辑...
|
||||
getTRTCStreamId(t) {
|
||||
const o = t.split("_"), r = o.slice(0, -1).join("_"), n = Number(o[o.length - 1]);
|
||||
return v(r, n);
|
||||
},
|
||||
bindTRTCCloudEvent() {
|
||||
i.on("playerAttributesChange", this.playerAttributesChange), i.on("playerAudioRouteChange", this.playerAudioRouteChange);
|
||||
},
|
||||
unbindTRTCCloudEvent() {
|
||||
i.off("playerAttributesChange", this.playerAttributesChange), i.off("playerAudioRouteChange", this.playerAudioRouteChange);
|
||||
},
|
||||
playerAttributesChange(t) {
|
||||
const { view: o, playerAttributes: r, callback: n } = t;
|
||||
o === this.streamId && (this.player = { ...this.player, ...r }, n && n());
|
||||
},
|
||||
playerAudioRouteChange(t) {
|
||||
const { soundMode: o, callback: r } = t;
|
||||
this.soundMode = o, r && r();
|
||||
},
|
||||
_playerStateChange(t) {
|
||||
c.playerEventHandler(t);
|
||||
},
|
||||
_playerFullscreenChange(t) {
|
||||
c.playerFullscreenChange(t);
|
||||
},
|
||||
_playerNetStatus(t) {
|
||||
c.playerNetStatus(t);
|
||||
},
|
||||
_playerAudioVolumeNotify(t) {
|
||||
try {
|
||||
t.currentTarget.dataset.streamid = this.player.streamID, c.playerAudioVolumeNotify(t);
|
||||
} catch (o) {
|
||||
s.logger.warn(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, M = { class: "trtc-player-container" }, x = {
|
||||
key: 1,
|
||||
class: "trtc-dark-mask"
|
||||
};
|
||||
function B(t, o, r, n, e, a) {
|
||||
const d = m("live-player");
|
||||
return h(), y("div", M, [
|
||||
r.streamId ? (h(), _(d, {
|
||||
key: 0,
|
||||
class: "trtc-player",
|
||||
id: e.player.streamID,
|
||||
"data-userid": e.player.userID,
|
||||
"data-streamid": e.player.streamID,
|
||||
"data-streamtype": e.player.streamType,
|
||||
src: e.player.src,
|
||||
mode: "RTC",
|
||||
autoplay: e.player.autoplay,
|
||||
"mute-audio": e.player.muteAudio,
|
||||
"mute-video": e.player.muteVideo,
|
||||
orientation: e.player.orientation,
|
||||
"object-fit": e.player.objectFit,
|
||||
"background-mute": e.player.enableBackgroundMute,
|
||||
"min-cache": e.player.minCache,
|
||||
"max-cache": e.player.maxCache,
|
||||
"sound-mode": e.soundMode,
|
||||
"enable-recv-message": e.player.enableRecvMessage,
|
||||
"auto-pause-if-navigate": e.player.autoPauseIfNavigate,
|
||||
"auto-pause-if-open-native": e.player.autoPauseIfOpenNative,
|
||||
debug: e.player.debug,
|
||||
onStatechange: a._playerStateChange,
|
||||
onFullscreenchange: a._playerFullscreenChange,
|
||||
onNetstatus: a._playerNetStatus,
|
||||
onAudiovolumenotify: a._playerAudioVolumeNotify
|
||||
}, null, 8, ["id", "data-userid", "data-streamid", "data-streamtype", "src", "autoplay", "mute-audio", "mute-video", "orientation", "object-fit", "background-mute", "min-cache", "max-cache", "sound-mode", "enable-recv-message", "auto-pause-if-navigate", "auto-pause-if-open-native", "debug", "onStatechange", "onFullscreenchange", "onNetstatus", "onAudiovolumenotify"])) : C("", !0),
|
||||
e.player.stopVideo ? (h(), y("div", x)) : C("", !0)
|
||||
]);
|
||||
}
|
||||
const N = /* @__PURE__ */ f(E, [["render", B], ["__scopeId", "data-v-645a3f31"]]), P = (t) => {
|
||||
t.component("TRTCPusher", S), t.component("TRTCPlayer", N);
|
||||
};
|
||||
export {
|
||||
N as TRTCPlayer,
|
||||
S as TRTCPusher,
|
||||
H as default,
|
||||
P as install
|
||||
};
|
||||
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
.trtc-pusher-container[data-v-c40920dd]{height:100%;width:100%;position:relative}.trtc-pusher[data-v-c40920dd]{height:100%;width:100%}.trtc-player[data-v-c40920dd]{width:0;height:0;display:flex}.trtc-player-container[data-v-645a3f31]{height:100%;width:100%;position:relative}.trtc-player[data-v-645a3f31]{height:100%;width:100%}.trtc-dark-mask[data-v-645a3f31]{width:100%;height:100%;background-color:#000;position:absolute;top:0}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"name": "@tencentcloud/trtc-component-uniapp",
|
||||
"version": "1.0.5",
|
||||
"description": "TRTC Uni-app Components for WeChat Mini Program",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tencentcloud/trtc-cloud-wx": "^1.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vue": "^2.6.0 || >=3.0.0",
|
||||
"@vitejs/plugin-vue": "^4.5.0",
|
||||
"vite": "^4.5.0",
|
||||
"typescript": "^5.0.2",
|
||||
"vue-tsc": "^1.8.5"
|
||||
},
|
||||
"keywords": [
|
||||
"trtc",
|
||||
"uni-app",
|
||||
"wechat",
|
||||
"video-call",
|
||||
"rtc"
|
||||
],
|
||||
"author": "Your Name",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
||||
Generated
Vendored
+164
@@ -0,0 +1,164 @@
|
||||
<template>
|
||||
<div class="trtc-player-container">
|
||||
<live-player
|
||||
v-if="streamId"
|
||||
class="trtc-player"
|
||||
:id="player.streamID"
|
||||
:data-userid="player.userID"
|
||||
:data-streamid="player.streamID"
|
||||
:data-streamtype="player.streamType"
|
||||
:src="player.src"
|
||||
mode="RTC"
|
||||
:autoplay="player.autoplay"
|
||||
:mute-audio="player.muteAudio"
|
||||
:mute-video="player.muteVideo"
|
||||
:orientation="player.orientation"
|
||||
:object-fit="player.objectFit"
|
||||
:background-mute="player.enableBackgroundMute"
|
||||
:min-cache="player.minCache"
|
||||
:max-cache="player.maxCache"
|
||||
:sound-mode="soundMode"
|
||||
:enable-recv-message="player.enableRecvMessage"
|
||||
:auto-pause-if-navigate="player.autoPauseIfNavigate"
|
||||
:auto-pause-if-open-native="player.autoPauseIfOpenNative"
|
||||
:debug="player.debug"
|
||||
@statechange="_playerStateChange"
|
||||
@fullscreenchange="_playerFullscreenChange"
|
||||
@netstatus="_playerNetStatus"
|
||||
@audiovolumenotify="_playerAudioVolumeNotify"
|
||||
/>
|
||||
<div v-if="player.stopVideo" class="trtc-dark-mask"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TRTCCloud, { translateTRTCStreamId } from '@tencentcloud/trtc-cloud-wx'
|
||||
|
||||
const trtcCloud = TRTCCloud.getTRTCShareInstance()
|
||||
const trtc = trtcCloud.trtc
|
||||
const InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter
|
||||
|
||||
export default {
|
||||
name: 'TRTCPlayer',
|
||||
props: {
|
||||
streamId: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
player: {},
|
||||
TRTCStreamId: '',
|
||||
soundMode: ''
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
streamId(newVal) {
|
||||
this.setTRTCStreamId(newVal)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
trtcCloud.logger.info('trtc-player attached', this.streamId)
|
||||
if (this.streamId) {
|
||||
InterfaceEventEmitter.emit('playerDomReady', { isReady: true, view: this.streamId })
|
||||
}
|
||||
this.TRTCStreamId = this.getTRTCStreamId(this.streamId)
|
||||
this.bindTRTCCloudEvent()
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.executeCleanup()
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.executeCleanup()
|
||||
},
|
||||
methods: {
|
||||
executeCleanup() {
|
||||
trtcCloud.logger.info('trtc-player detached', this.streamId)
|
||||
InterfaceEventEmitter.emit('playerDomReady', { isReady: false, streamId: this.streamId })
|
||||
this.unbindTRTCCloudEvent()
|
||||
},
|
||||
setTRTCStreamId(id) {
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId', id)
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
this.$emit('update:streamId', id)
|
||||
this.TRTCStreamId = this.getTRTCStreamId(id)
|
||||
this.$nextTick(() => {
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId success', id)
|
||||
resolve()
|
||||
InterfaceEventEmitter.emit('playerDomReady', { isReady: true, view: id })
|
||||
})
|
||||
} catch (err) {
|
||||
trtcCloud.logger.info('trtc-player setTRTCStreamId fail', id, err)
|
||||
reject(err)
|
||||
}
|
||||
})
|
||||
},
|
||||
// 其他方法保持原有逻辑...
|
||||
getTRTCStreamId(streamId) {
|
||||
const tempArray = streamId.split('_')
|
||||
const userId = tempArray.slice(0, -1).join('_')
|
||||
const streamType = Number(tempArray[tempArray.length - 1])
|
||||
return translateTRTCStreamId(userId, streamType)
|
||||
},
|
||||
bindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.on('playerAttributesChange', this.playerAttributesChange)
|
||||
InterfaceEventEmitter.on('playerAudioRouteChange', this.playerAudioRouteChange)
|
||||
},
|
||||
unbindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.off('playerAttributesChange', this.playerAttributesChange)
|
||||
InterfaceEventEmitter.off('playerAudioRouteChange', this.playerAudioRouteChange)
|
||||
},
|
||||
playerAttributesChange(event) {
|
||||
const { view, playerAttributes, callback } = event
|
||||
if (view === this.streamId) {
|
||||
this.player = { ...this.player, ...playerAttributes }
|
||||
callback && callback()
|
||||
}
|
||||
},
|
||||
playerAudioRouteChange(event) {
|
||||
const { soundMode, callback } = event
|
||||
this.soundMode = soundMode
|
||||
callback && callback()
|
||||
},
|
||||
_playerStateChange(event) {
|
||||
trtc.playerEventHandler(event)
|
||||
},
|
||||
_playerFullscreenChange(event) {
|
||||
trtc.playerFullscreenChange(event)
|
||||
},
|
||||
_playerNetStatus(event) {
|
||||
trtc.playerNetStatus(event)
|
||||
},
|
||||
_playerAudioVolumeNotify(event) {
|
||||
try {
|
||||
event.currentTarget.dataset.streamid = this.player.streamID
|
||||
trtc.playerAudioVolumeNotify(event)
|
||||
} catch (err) {
|
||||
trtcCloud.logger.warn(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.trtc-player-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.trtc-player {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
.trtc-dark-mask {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: black;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
Generated
Vendored
+142
@@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<div class="trtc-pusher-container">
|
||||
<live-pusher
|
||||
class="trtc-pusher"
|
||||
:url="pusher.url"
|
||||
mode="HD"
|
||||
:autopush="pusher.autopush"
|
||||
:enable-camera="pusher.enableCamera"
|
||||
:enable-mic="pusher.enableMic"
|
||||
:muted="pusher.muted"
|
||||
:enable-agc="pusher.enableAgc"
|
||||
:enable-ans="pusher.enableAns"
|
||||
:enable-ear-monitor="pusher.enableEarMonitor"
|
||||
:auto-focus="pusher.enableAutoFocus"
|
||||
:zoom="pusher.enableZoom"
|
||||
:min-bitrate="pusher.minBitrate"
|
||||
:max-bitrate="pusher.maxBitrate"
|
||||
:video-width="pusher.videoWidth"
|
||||
:video-height="pusher.videoHeight"
|
||||
:beauty="pusher.beautyLevel"
|
||||
:whiteness="pusher.whitenessLevel"
|
||||
:orientation="pusher.videoOrientation"
|
||||
:aspect="pusher.videoAspect"
|
||||
:device-position="pusher.frontCamera"
|
||||
:remote-mirror="pusher.enableRemoteMirror"
|
||||
:local-mirror="pusher.localMirror"
|
||||
:background-mute="pusher.enableBackgroundMute"
|
||||
:audio-quality="pusher.audioQuality"
|
||||
:audio-volume-type="pusher.audioVolumeType"
|
||||
:audio-reverb-type="pusher.audioReverbType"
|
||||
:waiting-image="pusher.waitingImage"
|
||||
:beauty-style="pusher.beautyStyle"
|
||||
:fps="pusher.fps"
|
||||
:filter="pusher.filter"
|
||||
@statechange="handleStateChange"
|
||||
@netstatus="handleNetStatus"
|
||||
@error="handleError"
|
||||
@bgmstart="handleBGMStart"
|
||||
@bgmprogress="handleBGMProgress"
|
||||
@bgmcomplete="handleBGMComplete"
|
||||
@audiovolumenotify="handleAudioVolumeNotify"
|
||||
/>
|
||||
<live-player class="trtc-player" :sound-mode="soundMode"></live-player>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import TRTCCloud from '@tencentcloud/trtc-cloud-wx'
|
||||
|
||||
const trtcCloud = TRTCCloud.getTRTCShareInstance()
|
||||
const trtc = trtcCloud.trtc
|
||||
const InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter
|
||||
|
||||
export default {
|
||||
name: 'TRTCPusher',
|
||||
data() {
|
||||
return {
|
||||
pusher: {},
|
||||
soundMode: ''
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
trtcCloud.logger.info('trtc-pusher attached')
|
||||
this.bindTRTCCloudEvent()
|
||||
InterfaceEventEmitter.emit('pusherDomReady', true)
|
||||
},
|
||||
beforeUnmount() {
|
||||
this.executeCleanup()
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.executeCleanup()
|
||||
},
|
||||
methods: {
|
||||
executeCleanup() {
|
||||
trtcCloud.logger.info('trtc-pusher detached')
|
||||
InterfaceEventEmitter.emit('pusherDomReady', false)
|
||||
this.unbindTRTCCloudEvent()
|
||||
trtcCloud.exitRoom()
|
||||
},
|
||||
pusherAttributesChange(event) {
|
||||
const { pusher, callback } = event
|
||||
this.pusher = { ...this.pusher, ...pusher }
|
||||
callback && this.$nextTick(callback)
|
||||
},
|
||||
playerAudioRouteChange(event) {
|
||||
const { soundMode, callback } = event
|
||||
this.soundMode = soundMode
|
||||
callback && callback()
|
||||
},
|
||||
bindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.on('pusherAttributesChange', this.pusherAttributesChange)
|
||||
InterfaceEventEmitter.on('playerAudioRouteChange', this.playerAudioRouteChange)
|
||||
},
|
||||
unbindTRTCCloudEvent() {
|
||||
InterfaceEventEmitter.off('pusherAttributesChange', this.pusherAttributesChange)
|
||||
InterfaceEventEmitter.off('playerAudioRouteChange', this.playerAudioRouteChange)
|
||||
},
|
||||
handleStateChange(event) {
|
||||
trtc.pusherEventHandler(event)
|
||||
},
|
||||
handleNetStatus(event) {
|
||||
trtc.pusherNetStatusHandler(event)
|
||||
},
|
||||
handleError(event) {
|
||||
trtc.pusherErrorHandler(event)
|
||||
},
|
||||
handleBGMStart(event) {
|
||||
trtc.pusherBGMStartHandler(event)
|
||||
},
|
||||
handleBGMProgress(event) {
|
||||
trtc.pusherBGMProgressHandler(event)
|
||||
},
|
||||
handleBGMComplete(event) {
|
||||
trtc.pusherBGMCompleteHandler(event)
|
||||
},
|
||||
handleAudioVolumeNotify(event) {
|
||||
if (!trtcCloud.isEnterRoom) return
|
||||
trtc.pusherAudioVolumeNotify(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.trtc-pusher-container {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.trtc-pusher {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.trtc-player {
|
||||
width: 0;
|
||||
height: 0;
|
||||
display: flex;
|
||||
}
|
||||
</style>
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import TRTCCloud from '@tencentcloud/trtc-cloud-wx'
|
||||
import TRTCPusher from './components/TRTCPusher.vue'
|
||||
import TRTCPlayer from './components/TRTCPlayer.vue'
|
||||
|
||||
// 导出TRTCCloud所有功能
|
||||
export * from '@tencentcloud/trtc-cloud-wx'
|
||||
|
||||
// 导出Vue组件
|
||||
export { TRTCPusher, TRTCPlayer }
|
||||
|
||||
// 默认导出TRTCCloud实例
|
||||
export default TRTCCloud
|
||||
|
||||
// 添加自动安装功能
|
||||
const install = (app) => {
|
||||
app.component('TRTCPusher', TRTCPusher)
|
||||
app.component('TRTCPlayer', TRTCPlayer)
|
||||
}
|
||||
|
||||
export { install }
|
||||
Reference in New Issue
Block a user