TP-89230 | callid and dispose call
This commit is contained in:
@@ -45,25 +45,48 @@ class AmeyoAdapter implements IAdapter {
|
||||
const
|
||||
_appendTags: () => void = () => {
|
||||
// Helper function to create and append elements
|
||||
function createElement(tag: string, attributes: GenericObject = {}, parent = document.body) {
|
||||
type ElementAttributes = {
|
||||
id?: string;
|
||||
className?: string;
|
||||
width?: string;
|
||||
height?: string;
|
||||
autoplay?: boolean;
|
||||
muted?: boolean;
|
||||
loop?: boolean;
|
||||
src?: string;
|
||||
style?: Partial<CSSStyleDeclaration>; // Explicitly type styles
|
||||
[key: string]: any; // Allow additional attributes
|
||||
};
|
||||
|
||||
function createElement(
|
||||
tag: keyof HTMLElementTagNameMap, // Ensure only valid HTML tags are used
|
||||
attributes: ElementAttributes = {},
|
||||
parent: HTMLElement = document.body
|
||||
): HTMLElement {
|
||||
const element = document.createElement(tag);
|
||||
|
||||
// Set attributes
|
||||
Object.keys(attributes).forEach(attr => {
|
||||
if (attr === 'style') {
|
||||
Object.assign(element.style, attributes.style); // Set styles
|
||||
Object.keys(attributes).forEach((attr) => {
|
||||
if (attr === 'style' && attributes.style) {
|
||||
// Safely assign styles
|
||||
Object.assign(element.style, attributes.style);
|
||||
} else if (attr in element) {
|
||||
// Type-safe assignment for known attributes
|
||||
(element as any)[attr] = attributes[attr];
|
||||
} else {
|
||||
element[attr] = attributes[attr]; // Set other attributes
|
||||
// Fallback for custom attributes
|
||||
element.setAttribute(attr, attributes[attr]);
|
||||
}
|
||||
});
|
||||
|
||||
// Append the element to the parent
|
||||
parent.appendChild(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
// Create audio and video elements dynamically
|
||||
createElement('audio', {
|
||||
id: 'audio_remote',
|
||||
autoplay: true
|
||||
autoplay: true,
|
||||
});
|
||||
|
||||
createElement('video', {
|
||||
@@ -77,8 +100,8 @@ class AmeyoAdapter implements IAdapter {
|
||||
opacity: '0',
|
||||
backgroundColor: '#000000',
|
||||
WebkitTransitionProperty: 'opacity',
|
||||
WebkitTransitionDuration: '2s'
|
||||
}
|
||||
WebkitTransitionDuration: '2s',
|
||||
},
|
||||
});
|
||||
|
||||
createElement('video', {
|
||||
@@ -91,8 +114,8 @@ class AmeyoAdapter implements IAdapter {
|
||||
opacity: '0',
|
||||
backgroundColor: '#000000',
|
||||
WebkitTransitionProperty: 'opacity',
|
||||
WebkitTransitionDuration: '2s'
|
||||
}
|
||||
WebkitTransitionDuration: '2s',
|
||||
},
|
||||
});
|
||||
|
||||
createElement('audio', {
|
||||
|
||||
Reference in New Issue
Block a user