mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Add _attachments to Audio and Video Track for Safari support
This commit is contained in:
Vendored
+8
@@ -39,6 +39,10 @@ export class AudioTrack extends Track {
|
||||
kind: 'audio';
|
||||
mediaStreamTrack: MediaStreamTrack;
|
||||
|
||||
// Required for Safari if you want to detach without errors
|
||||
// See: https://github.com/twilio/twilio-video.js/issues/294#issuecomment-389708981
|
||||
_attachments?: HTMLMediaElement[];
|
||||
|
||||
attach(element?: HTMLMediaElement | string): HTMLMediaElement;
|
||||
detach(element?: HTMLMediaElement | string): HTMLMediaElement[];
|
||||
}
|
||||
@@ -433,6 +437,10 @@ export class VideoTrack extends Track {
|
||||
kind: 'video';
|
||||
mediaStreamTrack: MediaStreamTrack;
|
||||
|
||||
// Required for Safari if you want to detach without errors
|
||||
// See: https://github.com/twilio/twilio-video.js/issues/294#issuecomment-389708981
|
||||
_attachments?: HTMLMediaElement[];
|
||||
|
||||
attach(element?: HTMLMediaElement | string): HTMLVideoElement;
|
||||
detach(element?: HTMLMediaElement | string): HTMLMediaElement[];
|
||||
}
|
||||
|
||||
@@ -63,10 +63,14 @@ function trackSubscribed(track: Video.VideoTrack | Video.AudioTrack) {
|
||||
|
||||
function trackUnsubscribed(track: Video.VideoTrack | Video.AudioTrack) {
|
||||
track.detach().forEach(element => element.remove());
|
||||
// Alternative if Safari crashes when detaching tracks
|
||||
track._attachments!.forEach((detachedElement) => detachedElement.remove());
|
||||
}
|
||||
|
||||
function insertDomElement(element: any) {
|
||||
function insertDomElement(element: HTMLMediaElement) {
|
||||
// Do something with the dom element
|
||||
document.createElement('div');
|
||||
element.appendChild(element);
|
||||
}
|
||||
|
||||
initRoom();
|
||||
|
||||
Reference in New Issue
Block a user