Commit 76a6f6b3 by qlintonger xeno

转换绝对引入为相对引入,AnyR=>.+

parent 186b7821
......@@ -180,94 +180,100 @@ export class Agora {
}
async preload() {
return new Promise((resolve) => {
const v = setInterval(() => {
if (window.AgoraRTC) {
clearInterval(v);
if (this.notUploadLog) {
AgoraRTC.disableLogUpload();
}
AgoraRTC.setLogLevel(this.logLevel);
this.AgoraClient = AgoraRTC.createClient({mode: this.mode, codec: this.codec});
this.AgoraClient.on('volume-indicator', function (volumes) {
chatChannelState.value.volumeSet = volumes;
})
console.log('client 已经创建', this.AgoraClient)
window.navigator.mediaDevices.enumerateDevices()
.then(function (info) {
const wholeCameraSet = info.filter(a => a.kind === 'videoinput');
webrtcStates.value.cameraDeviceSet = wholeCameraSet;
webrtcStates.value.isCameraAttached = wholeCameraSet.length > 0
webrtcStates.value.isMicroAttached = info.filter(a => a.kind === 'audioinput').length > 0;
console.log('当前设备状况', info, chatChannelState.value)
return new Promise((resolve, reject) => {
console.trace()
import("./AgoraRTC_N-4.19.1.js?url")
.then((url) => {
console.log('the url here', url)
const s = document.createElement('script');
s.src = url.default;
s.onerror = reject;
s.onload = () => {
if (this.notUploadLog) {
AgoraRTC.disableLogUpload();
}
AgoraRTC.setLogLevel(this.logLevel);
this.AgoraClient = AgoraRTC.createClient({mode: this.mode, codec: this.codec});
this.AgoraClient.on('volume-indicator', function (volumes) {
chatChannelState.value.volumeSet = volumes;
})
AgoraRTC.onCameraChanged = function () {
console.log('client 已经创建', this.AgoraClient)
window.navigator.mediaDevices.enumerateDevices()
.then(function (info) {
const wholeCameraSet = info.filter(a => a.kind === 'videoinput');
webrtcStates.value.cameraDeviceSet = wholeCameraSet;
webrtcStates.value.isCameraAttached = wholeCameraSet.length > 0
})
}
AgoraRTC.onMicrophoneChanged = function () {
window.navigator.mediaDevices.enumerateDevices()
.then(function (info) {
webrtcStates.value.isMicroAttached = info.filter(a => a.kind === 'audioinput').length > 0;
console.log('当前设备状况', info, chatChannelState.value)
})
}
this.AgoraClient.on('user-joined', (user) => {
const uidS = user.uid.toString()
const targetUser = userStates.value.onlineContacts.find(a => a.fromID.toString() === uidS);
console.log('在线用户加入了频道', targetUser)
targetUser.callState = 'calling'
if (!chatChannelState.value.currentChatters.includes(uidS)) {
chatChannelState.value.currentChatters.push(uidS)
AgoraRTC.onCameraChanged = function () {
window.navigator.mediaDevices.enumerateDevices()
.then(function (info) {
const wholeCameraSet = info.filter(a => a.kind === 'videoinput');
webrtcStates.value.cameraDeviceSet = wholeCameraSet;
webrtcStates.value.isCameraAttached = wholeCameraSet.length > 0
})
}
})
this.AgoraClient.on('user-left', (user) => {
const uidS = user.uid.toString()
const targetUser = userStates.value.onlineContacts.find(a => a.fromID.toString() === uidS);
console.log('在线用户离开了频道', targetUser)
if (chatChannelState.value.currentChatters.includes(uidS)) {
chatChannelState.value.currentChatters.splice(chatChannelState.value.currentChatters.indexOf(uidS), 1)
AgoraRTC.onMicrophoneChanged = function () {
window.navigator.mediaDevices.enumerateDevices()
.then(function (info) {
webrtcStates.value.isMicroAttached = info.filter(a => a.kind === 'audioinput').length > 0;
})
}
})
this.AgoraClient.on('user-published', (user, mediaType) => {
console.log('检测到远程用户发布媒体', user, mediaType);
if (user.uid.toString() !== this.data.uid.toString()) {
this.#subscribe(user, mediaType)
}
if (mediaType === 'audio') {
chatChannelState.value.mutedUserIdSet = chatChannelState.value.mutedUserIdSet.filter(i => i !== user.uid);
}
})
this.AgoraClient.on('user-unpublished', async (user, mediaType) => {
console.log('检测到远程用户取消发布媒体', user, mediaType);
if (user.uid.toString() !== this.data.uid.toString()) {
await this.AgoraClient.unsubscribe(user, mediaType);
}
if (mediaType === 'audio') {
if (!chatChannelState.value.mutedUserIdSet.includes(user.uid)) {
chatChannelState.value.mutedUserIdSet.push(user.uid);
this.AgoraClient.on('user-joined', (user) => {
const uidS = user.uid.toString()
const targetUser = userStates.value.onlineContacts.find(a => a.fromID.toString() === uidS);
console.log('在线用户加入了频道', targetUser)
targetUser.callState = 'calling'
if (!chatChannelState.value.currentChatters.includes(uidS)) {
chatChannelState.value.currentChatters.push(uidS)
}
user?.audioTrack?.stop()
}
if (mediaType === 'video') {
user?.videoTrack?.stop()
}
})
this.AgoraClient.on('network-quality', quality => {
if (chatChannelState.value.currentChatters.length === 0) {
return;
}
const {downlinkNetworkQuality: down, uplinkNetworkQuality: up} = quality
webrtcStates.value.networkQuality = {
down, up
};
})
resolve();
}
})
})
this.AgoraClient.on('user-left', (user) => {
const uidS = user.uid.toString()
const targetUser = userStates.value.onlineContacts.find(a => a.fromID.toString() === uidS);
console.log('在线用户离开了频道', targetUser)
if (chatChannelState.value.currentChatters.includes(uidS)) {
chatChannelState.value.currentChatters.splice(chatChannelState.value.currentChatters.indexOf(uidS), 1)
}
})
this.AgoraClient.on('user-published', (user, mediaType) => {
console.log('检测到远程用户发布媒体', user, mediaType);
if (user.uid.toString() !== this.data.uid.toString()) {
this.#subscribe(user, mediaType)
}
if (mediaType === 'audio') {
chatChannelState.value.mutedUserIdSet = chatChannelState.value.mutedUserIdSet.filter(i => i !== user.uid);
}
})
this.AgoraClient.on('user-unpublished', async (user, mediaType) => {
console.log('检测到远程用户取消发布媒体', user, mediaType);
if (user.uid.toString() !== this.data.uid.toString()) {
await this.AgoraClient.unsubscribe(user, mediaType);
}
if (mediaType === 'audio') {
if (!chatChannelState.value.mutedUserIdSet.includes(user.uid)) {
chatChannelState.value.mutedUserIdSet.push(user.uid);
}
user?.audioTrack?.stop()
}
if (mediaType === 'video') {
user?.videoTrack?.stop()
}
})
this.AgoraClient.on('network-quality', quality => {
if (chatChannelState.value.currentChatters.length === 0) {
return;
}
const {downlinkNetworkQuality: down, uplinkNetworkQuality: up} = quality
webrtcStates.value.networkQuality = {
down, up
};
})
resolve();
}
document.body.append(s);
})
})
}
......
......@@ -9,6 +9,5 @@
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<script defer async src="./AgoraRTC_N-4.19.1.js"></script>
</body>
</html>
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -33,7 +33,8 @@ export default defineConfig({
AutoImport({
imports: ['vue', 'vue-router'],
dts: 'src/auto-import.d.ts',
resolvers: [ArcoResolver()]
resolvers: [ArcoResolver()],
exclude: ['anyremote/agora/AgoraRTC_N-4.19.1.js']
}),
Components({
// 自动导入的组件位置,默认是src/components
......@@ -71,6 +72,6 @@ export default defineConfig({
cors: true // 跨域
},
optimizeDeps: {
exclude: ['AnyR/agora/AgoraRTC_N-4.19.1.js']
exclude: ['anyremote/agora/AgoraRTC_N-4.19.1.js']
}
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment