@tencentcloud/trtc-component-wx 1.0.3-beta.2 → 1.0.3-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/TRTCPlayer.vue +0 -157
- package/src/TRTCPusher.vue +0 -136
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tencentcloud/trtc-component-wx",
|
|
3
|
-
"version": "1.0.3-beta.
|
|
3
|
+
"version": "1.0.3-beta.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "miniprogram_dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -67,6 +67,6 @@
|
|
|
67
67
|
"webpack-node-externals": "^1.7.2"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@tencentcloud/trtc-cloud-wx": "
|
|
70
|
+
"@tencentcloud/trtc-cloud-wx": "1.0.2-beta.1"
|
|
71
71
|
}
|
|
72
72
|
}
|
package/src/TRTCPlayer.vue
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="trtc-player-container">
|
|
3
|
-
<live-player
|
|
4
|
-
v-if="streamId"
|
|
5
|
-
:id="player.streamID"
|
|
6
|
-
:data-userid="player.userID"
|
|
7
|
-
:data-streamid="player.streamID"
|
|
8
|
-
:data-streamtype="player.streamType"
|
|
9
|
-
:src="player.src"
|
|
10
|
-
mode="RTC"
|
|
11
|
-
:autoplay="player.autoplay"
|
|
12
|
-
:mute-audio="player.muteAudio"
|
|
13
|
-
:mute-video="player.muteVideo"
|
|
14
|
-
:orientation="player.orientation"
|
|
15
|
-
:object-fit="player.objectFit"
|
|
16
|
-
:background-mute="player.enableBackgroundMute"
|
|
17
|
-
:min-cache="player.minCache"
|
|
18
|
-
:max-cache="player.maxCache"
|
|
19
|
-
:sound-mode="soundMode"
|
|
20
|
-
:enable-recv-message="player.enableRecvMessage"
|
|
21
|
-
:auto-pause-if-navigate="player.autoPauseIfNavigate"
|
|
22
|
-
:auto-pause-if-open-native="player.autoPauseIfOpenNative"
|
|
23
|
-
:debug="player.debug"
|
|
24
|
-
@statechange="_playerStateChange"
|
|
25
|
-
@fullscreenchange="_playerFullscreenChange"
|
|
26
|
-
@netstatus="_playerNetStatus"
|
|
27
|
-
@audiovolumenotify="_playerAudioVolumeNotify"
|
|
28
|
-
/>
|
|
29
|
-
<div v-if="player.stopVideo" class="trtc-dark-mask"></div>
|
|
30
|
-
</div>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<script>
|
|
34
|
-
import { translateTRTCStreamId } from '@tencentcloud/trtc-cloud-wx'
|
|
35
|
-
import TRTCCloud, { trtc } from '@tencentcloud/trtc-cloud-wx'
|
|
36
|
-
import { InterfaceEventEmitter } from '@tencentcloud/trtc-cloud-wx'
|
|
37
|
-
|
|
38
|
-
const trtcCloud = TRTCCloud.getTRTCShareInstance()
|
|
39
|
-
|
|
40
|
-
export default {
|
|
41
|
-
name: 'TRTCPlayer',
|
|
42
|
-
props: {
|
|
43
|
-
streamId: {
|
|
44
|
-
type: String,
|
|
45
|
-
default: ''
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
data() {
|
|
49
|
-
return {
|
|
50
|
-
player: {},
|
|
51
|
-
TRTCStreamId: '',
|
|
52
|
-
soundMode: ''
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
watch: {
|
|
56
|
-
streamId(newVal) {
|
|
57
|
-
this.setTRTCStreamId(newVal)
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
mounted() {
|
|
61
|
-
trtcCloud.logger.info('trtc-player attached', this.streamId)
|
|
62
|
-
if (this.streamId) {
|
|
63
|
-
InterfaceEventEmitter.emit('playerDomReady', { isReady: true, view: this.streamId })
|
|
64
|
-
}
|
|
65
|
-
this.TRTCStreamId = this.getTRTCStreamId(this.streamId)
|
|
66
|
-
this.bindTRTCCloudEvent()
|
|
67
|
-
},
|
|
68
|
-
beforeUnmount() {
|
|
69
|
-
trtcCloud.logger.info('trtc-player detached', this.streamId)
|
|
70
|
-
InterfaceEventEmitter.emit('playerDomReady', { isReady: false, streamId: this.streamId })
|
|
71
|
-
this.unbindTRTCCloudEvent()
|
|
72
|
-
},
|
|
73
|
-
methods: {
|
|
74
|
-
setTRTCStreamId(id) {
|
|
75
|
-
trtcCloud.logger.info('trtc-player setTRTCStreamId', id)
|
|
76
|
-
return new Promise((resolve, reject) => {
|
|
77
|
-
try {
|
|
78
|
-
this.$emit('update:streamId', id)
|
|
79
|
-
this.TRTCStreamId = this.getTRTCStreamId(id)
|
|
80
|
-
this.$nextTick(() => {
|
|
81
|
-
trtcCloud.logger.info('trtc-player setTRTCStreamId success', id)
|
|
82
|
-
resolve()
|
|
83
|
-
InterfaceEventEmitter.emit('playerDomReady', { isReady: true, view: id })
|
|
84
|
-
})
|
|
85
|
-
} catch (err) {
|
|
86
|
-
trtcCloud.logger.info('trtc-player setTRTCStreamId fail', id, err)
|
|
87
|
-
reject(err)
|
|
88
|
-
}
|
|
89
|
-
})
|
|
90
|
-
},
|
|
91
|
-
// 其他方法保持原有逻辑...
|
|
92
|
-
getTRTCStreamId(streamId) {
|
|
93
|
-
const tempArray = streamId.split('_')
|
|
94
|
-
const userId = tempArray.slice(0, -1).join('_')
|
|
95
|
-
const streamType = Number(tempArray[tempArray.length - 1])
|
|
96
|
-
return translateTRTCStreamId(userId, streamType)
|
|
97
|
-
},
|
|
98
|
-
bindTRTCCloudEvent() {
|
|
99
|
-
InterfaceEventEmitter.on('playerAttributesChange', this.playerAttributesChange)
|
|
100
|
-
InterfaceEventEmitter.on('playerAudioRouteChange', this.playerAudioRouteChange)
|
|
101
|
-
},
|
|
102
|
-
unbindTRTCCloudEvent() {
|
|
103
|
-
InterfaceEventEmitter.off('playerAttributesChange', this.playerAttributesChange)
|
|
104
|
-
InterfaceEventEmitter.off('playerAudioRouteChange', this.playerAudioRouteChange)
|
|
105
|
-
},
|
|
106
|
-
playerAttributesChange(event) {
|
|
107
|
-
const { view, playerAttributes, callback } = event
|
|
108
|
-
if (view === this.streamId) {
|
|
109
|
-
this.player = { ...this.player, ...playerAttributes }
|
|
110
|
-
callback && callback()
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
playerAudioRouteChange(event) {
|
|
114
|
-
const { soundMode, callback } = event
|
|
115
|
-
this.soundMode = soundMode
|
|
116
|
-
callback && callback()
|
|
117
|
-
},
|
|
118
|
-
_playerStateChange(event) {
|
|
119
|
-
trtc.playerEventHandler(event)
|
|
120
|
-
},
|
|
121
|
-
_playerFullscreenChange(event) {
|
|
122
|
-
trtc.playerFullscreenChange(event)
|
|
123
|
-
},
|
|
124
|
-
_playerNetStatus(event) {
|
|
125
|
-
trtc.playerNetStatus(event)
|
|
126
|
-
},
|
|
127
|
-
_playerAudioVolumeNotify(event) {
|
|
128
|
-
try {
|
|
129
|
-
event.currentTarget.dataset.streamid = this.player.streamID
|
|
130
|
-
trtc.playerAudioVolumeNotify(event)
|
|
131
|
-
} catch (err) {
|
|
132
|
-
trtcCloud.logger.warn(err)
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
</script>
|
|
138
|
-
|
|
139
|
-
<style scoped>
|
|
140
|
-
.trtc-player-container {
|
|
141
|
-
height: 100%;
|
|
142
|
-
width: 100%;
|
|
143
|
-
position: relative;
|
|
144
|
-
}
|
|
145
|
-
.trtc-player {
|
|
146
|
-
height: 100%;
|
|
147
|
-
width: 100%;
|
|
148
|
-
}
|
|
149
|
-
.trtc-dark-mask {
|
|
150
|
-
width: 100%;
|
|
151
|
-
height: 100%;
|
|
152
|
-
background-color: black;
|
|
153
|
-
position: absolute;
|
|
154
|
-
top: 0;
|
|
155
|
-
}
|
|
156
|
-
</style>
|
|
157
|
-
|
package/src/TRTCPusher.vue
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="trtc-pusher-container">
|
|
3
|
-
<live-pusher
|
|
4
|
-
class="trtc-pusher"
|
|
5
|
-
:url="pusher.url"
|
|
6
|
-
mode="HD"
|
|
7
|
-
:autopush="pusher.autopush"
|
|
8
|
-
:enable-camera="pusher.enableCamera"
|
|
9
|
-
:enable-mic="pusher.enableMic"
|
|
10
|
-
:muted="pusher.muted"
|
|
11
|
-
:enable-agc="pusher.enableAgc"
|
|
12
|
-
:enable-ans="pusher.enableAns"
|
|
13
|
-
:enable-ear-monitor="pusher.enableEarMonitor"
|
|
14
|
-
:auto-focus="pusher.enableAutoFocus"
|
|
15
|
-
:zoom="pusher.enableZoom"
|
|
16
|
-
:min-bitrate="pusher.minBitrate"
|
|
17
|
-
:max-bitrate="pusher.maxBitrate"
|
|
18
|
-
:video-width="pusher.videoWidth"
|
|
19
|
-
:video-height="pusher.videoHeight"
|
|
20
|
-
:beauty="pusher.beautyLevel"
|
|
21
|
-
:whiteness="pusher.whitenessLevel"
|
|
22
|
-
:orientation="pusher.videoOrientation"
|
|
23
|
-
:aspect="pusher.videoAspect"
|
|
24
|
-
:device-position="pusher.frontCamera"
|
|
25
|
-
:remote-mirror="pusher.enableRemoteMirror"
|
|
26
|
-
:local-mirror="pusher.localMirror"
|
|
27
|
-
:background-mute="pusher.enableBackgroundMute"
|
|
28
|
-
:audio-quality="pusher.audioQuality"
|
|
29
|
-
:audio-volume-type="pusher.audioVolumeType"
|
|
30
|
-
:audio-reverb-type="pusher.audioReverbType"
|
|
31
|
-
:waiting-image="pusher.waitingImage"
|
|
32
|
-
:beauty-style="pusher.beautyStyle"
|
|
33
|
-
:fps="pusher.fps"
|
|
34
|
-
:filter="pusher.filter"
|
|
35
|
-
@statechange="handleStateChange"
|
|
36
|
-
@netstatus="handleNetStatus"
|
|
37
|
-
@error="handleError"
|
|
38
|
-
@bgmstart="handleBGMStart"
|
|
39
|
-
@bgmprogress="handleBGMProgress"
|
|
40
|
-
@bgmcomplete="handleBGMComplete"
|
|
41
|
-
@audiovolumenotify="handleAudioVolumeNotify"
|
|
42
|
-
/>
|
|
43
|
-
<live-player class="trtc-player" :sound-mode="soundMode"></live-player>
|
|
44
|
-
</div>
|
|
45
|
-
</template>
|
|
46
|
-
|
|
47
|
-
<script>
|
|
48
|
-
import TRTCCloud from '@tencentcloud/trtc-cloud-wx'
|
|
49
|
-
|
|
50
|
-
const trtcCloud = TRTCCloud.getTRTCShareInstance()
|
|
51
|
-
const trtc = trtcCloud.trtc
|
|
52
|
-
const InterfaceEventEmitter = trtcCloud.InterfaceEventEmitter
|
|
53
|
-
|
|
54
|
-
export default {
|
|
55
|
-
name: 'TRTCPusher',
|
|
56
|
-
data() {
|
|
57
|
-
return {
|
|
58
|
-
pusher: {},
|
|
59
|
-
soundMode: ''
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
mounted() {
|
|
63
|
-
trtcCloud.logger.info('trtc-pusher attached')
|
|
64
|
-
this.bindTRTCCloudEvent()
|
|
65
|
-
InterfaceEventEmitter.emit('pusherDomReady', true)
|
|
66
|
-
},
|
|
67
|
-
beforeUnmount() {
|
|
68
|
-
trtcCloud.logger.info('trtc-pusher detached')
|
|
69
|
-
InterfaceEventEmitter.emit('pusherDomReady', false)
|
|
70
|
-
this.unbindTRTCCloudEvent()
|
|
71
|
-
trtcCloud.exitRoom()
|
|
72
|
-
},
|
|
73
|
-
methods: {
|
|
74
|
-
pusherAttributesChange(event) {
|
|
75
|
-
const { pusher, callback } = event
|
|
76
|
-
this.pusher = { ...this.pusher, ...pusher }
|
|
77
|
-
callback && this.$nextTick(callback)
|
|
78
|
-
},
|
|
79
|
-
playerAudioRouteChange(event) {
|
|
80
|
-
const { soundMode, callback } = event
|
|
81
|
-
this.soundMode = soundMode
|
|
82
|
-
callback && callback()
|
|
83
|
-
},
|
|
84
|
-
bindTRTCCloudEvent() {
|
|
85
|
-
InterfaceEventEmitter.on('pusherAttributesChange', this.pusherAttributesChange)
|
|
86
|
-
InterfaceEventEmitter.on('playerAudioRouteChange', this.playerAudioRouteChange)
|
|
87
|
-
},
|
|
88
|
-
unbindTRTCCloudEvent() {
|
|
89
|
-
InterfaceEventEmitter.off('pusherAttributesChange', this.pusherAttributesChange)
|
|
90
|
-
InterfaceEventEmitter.off('playerAudioRouteChange', this.playerAudioRouteChange)
|
|
91
|
-
},
|
|
92
|
-
handleStateChange(event) {
|
|
93
|
-
trtc.pusherEventHandler(event)
|
|
94
|
-
},
|
|
95
|
-
handleNetStatus(event) {
|
|
96
|
-
trtc.pusherNetStatusHandler(event)
|
|
97
|
-
},
|
|
98
|
-
handleError(event) {
|
|
99
|
-
trtc.pusherErrorHandler(event)
|
|
100
|
-
},
|
|
101
|
-
handleBGMStart(event) {
|
|
102
|
-
trtc.pusherBGMStartHandler(event)
|
|
103
|
-
},
|
|
104
|
-
handleBGMProgress(event) {
|
|
105
|
-
trtc.pusherBGMProgressHandler(event)
|
|
106
|
-
},
|
|
107
|
-
handleBGMComplete(event) {
|
|
108
|
-
trtc.pusherBGMCompleteHandler(event)
|
|
109
|
-
},
|
|
110
|
-
handleAudioVolumeNotify(event) {
|
|
111
|
-
if (!trtcCloud.isEnterRoom) return
|
|
112
|
-
trtc.pusherAudioVolumeNotify(event)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
</script>
|
|
117
|
-
|
|
118
|
-
<style scoped>
|
|
119
|
-
.trtc-pusher-container {
|
|
120
|
-
height: 100%;
|
|
121
|
-
width: 100%;
|
|
122
|
-
position: relative;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.trtc-pusher {
|
|
126
|
-
height: 100%;
|
|
127
|
-
width: 100%;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.trtc-player {
|
|
131
|
-
width: 0;
|
|
132
|
-
height: 0;
|
|
133
|
-
display: flex;
|
|
134
|
-
}
|
|
135
|
-
</style>
|
|
136
|
-
|