Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0] CS-125: add the ability to select a ring audio device (#84) #85

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions docs/lwpMediaDevices.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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:

Expand All @@ -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()
Expand All @@ -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 |
Expand All @@ -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 |
Expand Down Expand Up @@ -202,6 +210,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() |
Expand Down
32 changes: 29 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@
elementId: "media_device_tweaked",
},
data: {
ringoutput: { show: false },
audiooutput: { show: false },
audioinput: { show: false },
},
Expand Down Expand Up @@ -531,6 +532,21 @@
<legend>{{i18n.legend}}</legend>

{{#data.loaded}}
<div>
<label for="ringoutput">
{{i18n.ringoutput}}
</label>
<fieldset id="ringoutput">
{{#data.ringoutput.devices}}
{{#connected}}
<div><input type="radio" value="{{id}}" name="{{by_name.ringoutputselector.elementName}}" {{#selected}}checked{{/selected}}>{{name}}</input></div>
{{/connected}}
{{/data.ringoutput.devices}}
</fieldset>
</div>

<br>

<div>
<label for="audiooutput">
{{i18n.audiooutput}}
Expand Down Expand Up @@ -588,10 +604,20 @@
elementId: "media_device_custom",
},
by_name: {
ringoutputselector: {
events: {
onchange: (event) => {
const element = event.srcElement;
webphone
.getMediaDevices()
.changeDevice("ringoutput", element.value);
},
},
},
audiooutputselector: {
events: {
onchange: (event) => {
let element = event.srcElement;
const element = event.srcElement;
webphone
.getMediaDevices()
.changeDevice("audiooutput", element.value);
Expand All @@ -601,7 +627,7 @@
audiooinputselector: {
events: {
onchange: (event) => {
let element = event.srcElement;
const element = event.srcElement;
webphone
.getMediaDevices()
.changeDevice("audioinput", element.value);
Expand All @@ -611,7 +637,7 @@
videoinputselector: {
events: {
onchange: (event) => {
let element = event.srcElement;
const element = event.srcElement;
webphone
.getMediaDevices()
.changeDevice("videoinput", element.value);
Expand Down
Loading