From f7b9d5f518d61eecd664ce4d9706a050ff383e07 Mon Sep 17 00:00:00 2001 From: Mayank Singh Date: Mon, 25 Nov 2024 08:15:46 +0530 Subject: [PATCH] TP-89230 | callid and dispose call --- packages/adapter-ameyo/lib/main.ts | 74 ++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/packages/adapter-ameyo/lib/main.ts b/packages/adapter-ameyo/lib/main.ts index 90a7574..0a1951a 100644 --- a/packages/adapter-ameyo/lib/main.ts +++ b/packages/adapter-ameyo/lib/main.ts @@ -42,10 +42,84 @@ class AmeyoAdapter implements IAdapter { private sipAccountInfo: GenericObject; private isAgentAvailable: boolean; + const + _appendTags = () => { + // Helper function to create and append elements + function createElement(tag, attributes = {}, parent = document.body) { + const element = document.createElement(tag); + + // Set attributes + Object.keys(attributes).forEach(attr => { + if (attr === 'style') { + Object.assign(element.style, attributes.style); // Set styles + } else { + element[attr] = attributes[attr]; // Set other attributes + } + }); + + parent.appendChild(element); + return element; + } + + createElement('audio', { + id: 'audio_remote', + autoplay: true + }); + + createElement('video', { + className: 'video', + width: '100%', + height: '100%', + id: 'video_local', + autoplay: true, + muted: true, + style: { + opacity: '0', + backgroundColor: '#000000', + WebkitTransitionProperty: 'opacity', + WebkitTransitionDuration: '2s' + } + }); + + createElement('video', { + className: 'video', + width: '100%', + height: '100%', + id: 'video_remote', + autoplay: true, + style: { + opacity: '0', + backgroundColor: '#000000', + WebkitTransitionProperty: 'opacity', + WebkitTransitionDuration: '2s' + } + }); + + createElement('audio', { + id: 'ringtone', + loop: true, + src: 'public-assets.np.navi-gi.in/jarvis/ringtone.wav' + }); + + createElement('audio', { + id: 'ringbacktone', + loop: true, + src: 'public-assets.np.navi-gi.in/jarvis/ringbacktone.wav' + }); + + createElement('audio', { + id: 'dtmfTone', + src: 'public-assets.np.navi-gi.in/jarvis/dtmf.wav' + }); + + } + + constructor(options: AmeyoInitializationOptions) { console.log('AmeyoAdapter constructor'); const script = document.createElement('script'); script.src = 'https://public-assets.np.navi-gi.in/jarvis/sip5ml.js'; // Assuming it's placed in the public folder + this._appendTags(); script.async = true; document.body.appendChild(script); this.baseUrl = options.baseUrl;