From 4062c2ae3d03e429d1513241857ef6c4bea2286e Mon Sep 17 00:00:00 2001 From: Alex Navarro Date: Fri, 28 Jul 2023 15:05:35 -0600 Subject: [PATCH] CS-125: add the ability to select a ring audio device --- docs/lwpMediaDevices.md | 19 +- index.html | 32 +- package-lock.json | 8279 +++++++++++++++++++++++++++++++++++++-- src/lwpAudioContext.js | 36 +- src/lwpMediaDevices.js | 116 +- 5 files changed, 8209 insertions(+), 273 deletions(-) diff --git a/docs/lwpMediaDevices.md b/docs/lwpMediaDevices.md index fc3a566..e3c24df 100644 --- a/docs/lwpMediaDevices.md +++ b/docs/lwpMediaDevices.md @@ -85,7 +85,7 @@ Get the HTML media element linked to the provided device kind. | Name | Type | Default | Description | | ---------- | ------ | ------- | -------------------------------------------------------------------------------------- | -| deviceKind | string | | The device kind linked to the HTML media element (audiooutput, audioinput, videoinput) | +| deviceKind | string | | The device kind linked to the HTML media element (ringoutput, audiooutput, audioinput, videoinput) | Returns: @@ -99,7 +99,7 @@ Get the prefered device for the given device kind. | Name | Type | Default | Description | | ---------- | ------ | ------- | ------------------------------------------------------------- | -| deviceKind | string | | The device kind to get (audiooutput, audioinput, videoinput) | +| deviceKind | string | | The device kind to get (ringoutput, audiooutput, audioinput, videoinput) | Returns: @@ -113,7 +113,7 @@ For the provided device kind attmpet to switch to the provided device id, updati | Name | Type | Default | Description | | ---------- | ------ | ------- | --------------------------------------------------------------- | -| deviceKind | string | | The device kind to switch (audiooutput, audioinput, videoinput) | +| deviceKind | string | | The device kind to switch (ringoutput, audiooutput, audioinput, videoinput) | | deviceId | string | | The device id to switch to | #### refreshAvailableDevices() @@ -129,6 +129,7 @@ Re-paint / update all render targets. | Key | Default (en) | Description | | ----------- | ------------------------ | ------------------------------------------------------------------------------------ | | none | None | Used as the text for a 'null' selection that can be used to disable that device kind | +| ringoutput | Speaker | Used to label the selector for the ring audio output device | | audiooutput | Speaker | Used to label the selector for the audio output device | | audioinput | Microphone | Used to label the selector for the audio input device | | videoinput | Camera | Used to lable the selector for the video input device | @@ -138,6 +139,13 @@ Re-paint / update all render targets. | Name | Type | Default | Description | | --------------------------------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| ringoutput.enabled | boolean | true if sinkId in HtmlMediaElement | Enables ringing output device selection | +| ringoutput.show | boolean | true | Should the default template show the ringing output device selection | +| ringoutput.preferedDeviceIds | array of strings | [] | The prefered device ids in order of precedence | +| ringoutput.mediaElement.create | boolean | true | Should a HTMLMediaElement be created | +| ringoutput.mediaElement.elementId | string | | The HTML id of an existing HTMLMediaElement to use | +| ringoutput.mediaElement.element | HTMLMediaElement | | The HTMLMediaElement linked to the output device selection | +| ringoutput.mediaElement.initParameters | object | { muted: false } | Key - value pairs to apply to the HTMLMediaElement | | audiooutput.enabled | boolean | true if sinkId in HtmlMediaElement | Enables audio output device selection | | audiooutput.show | boolean | true | Should the default template show the output device selection | | audiooutput.preferedDeviceIds | array of strings | [] | The prefered device ids in order of precedence | @@ -174,10 +182,12 @@ Re-paint / update all render targets. | mediaDevices.created | | Emitted when the class is instantiated | | mediaDevices.streams.started | [mediaStream](https://developer.mozilla.org/en-US/docs/Web/API/MediaStream) | Emitted when streams are started for a call | | mediaDevices.streams.stopped | | Emitted when streams are stopped for a call | +| mediaDevices.ring.output.element | [HTML Audio Element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) | Emitted when the HTML audio element is created | | mediaDevices.audio.output.element | [HTML Audio Element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) | Emitted when the HTML audio element is created | | mediaDevices.audio.input.element | [HTML Audio Element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) | Emitted when the HTML audio element is created | | mediaDevices.video.output.element | [HTML Video Element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video) | Emitted when the HTML audio element is created | | mediaDevices.getUserMedia.error | error (exception) | Emitted if getUserMedia() throws | +| mediaDevices.ring.output.changed | preferedDevice | Emitted when the ring output audio device is changed | | mediaDevices.audio.output.changed | preferedDevice | Emitted when the output audio device is changed | | mediaDevices.audio.input.muted | trackParameters (lwpUtil.trackParameters) | Emitted when the input audio is muted | | mediaDevices.video.input.muted | trackParameters (lwpUtil.trackParameters) | Emitted when the input audio is muted | @@ -191,7 +201,7 @@ Re-paint / update all render targets. | mediaDevices.video.input.stopped | trackParameters (lwpUtil.trackParameters) | Emitted when the video input is stopped | | mediaDevices.loaded | availableDevices | Emitted when the devices are initialized | | mediaDevices.refreshed | availableDevices | Emitted when the devices are changed | -> NOTE! All standard HTML media events for the audio output, audio input and video input elements are emitted as mediaDevices.{kind}.{direction}.{eventName} with the additional parameters: element (HTML element), event (HTML media event). For example, mediaDevices.audio.input.playing. +> NOTE! All standard HTML media events for the audio ringing, audio output, audio input and video input elements are emitted as mediaDevices.{kind}.{direction}.{eventName} with the additional parameters: element (HTML element), event (HTML media event). For example, mediaDevices.audio.input.playing. ### Consumed @@ -203,6 +213,7 @@ Re-paint / update all render targets. | audioContext.started | Invokes \_startMediaElements() | | mediaDevices.streams.started | Invokes updateRenders() | | mediaDevices.streams.stop | Invokes updateRenders() | +| mediaDevices.ring.output.changed | Invokes updateRenders() | | mediaDevices.audio.output.changed | Invokes updateRenders() | | mediaDevices.audio.input.changed | Invokes updateRenders() | | mediaDevices.video.input.changed | Invokes updateRenders() | diff --git a/index.html b/index.html index 8e926b4..d4a5fa1 100644 --- a/index.html +++ b/index.html @@ -379,6 +379,7 @@ elementId: "media_device_tweaked", }, data: { + ringoutput: { show: false }, audiooutput: { show: false }, audioinput: { show: false }, }, @@ -531,6 +532,21 @@ {{i18n.legend}} {{#data.loaded}} +
+ +
+ {{#data.ringoutput.devices}} + {{#connected}} +
{{name}}
+ {{/connected}} + {{/data.ringoutput.devices}} +
+
+ +
+