我正在尝试使用AntMedia实现 Livestream ,所以我有这个 Angular 10 项目,我需要在其中导入 webrtc_adaptor.js。
我的 webrtc_adaptor.js 是这样开始的:
function WebRTCAdaptor(initialValues)
{
class PeerStats {
constructor(streamId) {
this.streamId = streamId;
this.totalBytesReceivedCount = 0;
this.totalBytesSent = 0;
this.packetsLost = 0;
this.fractionLost = 0;
this.startTime = 0;
this.lastBytesReceived = 0;
this.lastBytesSent = 0;
this.currentTimestamp = 0;
this.lastTime = 0;
this.timerId = 0;
this.firstByteSentCount = 0;
this.firstBytesReceivedCount = 0;
this.audioLevel = -1;
}
}
要导入它,我将它添加到我的 angular.json 以下行:
"scripts": [
"src/main/webapp/app/entities/master/livestream/video/webrtc_adaptor.js"
]
在我的 Angular 组件中,我添加了:
declare let WebRTCAdaptor: any;
在我的课堂上,我补充说:
webRTCAdaptor: any;
this.webRTCAdaptor = new WebRTCAdaptor({
websocket_url : "wss://your_server_url:5443/WebRTCAppEE/websocket",
mediaConstraints : mediaConstraints,
peerconnection_config : pc_config,
sdp_constraints : sdpConstraints,
remoteVideoId : "remoteVideo",
isPlayMode: true,
debug: true,
callback : function(info, description)
});
我基于AntMedia 手册来执行此操作,毕竟我仍然收到以下错误:
ERROR ReferenceError: WebRTCAdaptor is not defined
at VideoComponent.startLive (video.component.ts?a313:85)
at VideoComponent.onSuccess (video.component.ts?a313:110)
at SafeSubscriber.eval [as _next] (video.component.ts?a313:78)
at SafeSubscriber.__tryOrUnsub (Subscriber.js?ee8f:183)
at SafeSubscriber.next (Subscriber.js?ee8f:122)
at Subscriber._next (Subscriber.js?ee8f:72)
at Subscriber.next (Subscriber.js?ee8f:49)
at MapSubscriber._next (map.js?949c:35)
at MapSubscriber.next (Subscriber.js?ee8f:49)
at FilterSubscriber._next (filter.js?a4b6:33)
有人可以帮我找出我做错了什么吗?
谢谢。