Skip to content

Commit

Permalink
feature: call hangup sound improved [WTEL-5123]
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirBeria committed Sep 17, 2024
1 parent 5e0b40a commit ee2eaa9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@vuelidate/validators": "^2.0.4",
"@vueuse/core": "^11.0.3",
"@webitel/flow-ui-sdk": "^0.1.14",
"@webitel/ui-sdk": "^24.10.10",
"@webitel/ui-sdk": "^24.10.11",
"axios": "^1.7.7",
"clipboard-copy": "^4.0.1",
"cron-validator": "^1.3.1",
Expand Down
26 changes: 3 additions & 23 deletions src/modules/settings/components/ringtone-volume-control.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@

<script>
import debounce from '@webitel/ui-sdk/src/scripts/debounce';
import triggerSound from '@webitel/ui-sdk/src/modules/Notifications/assets/audio/triggerSound';
export default {
data() {
return {
ringtoneVolume: 0.5, // Default ringtoneVolume level
ringtoneVolume: 1, // Default ringtoneVolume level
isRingtoneVolumeSaved: false,
audioCtx: null, // Audio context will be created upon user interaction
};
},
methods: {
Expand All @@ -57,29 +57,9 @@ export default {
localStorage.setItem('settings/ringtone-volume', this.ringtoneVolume);
this.isRingtoneVolumeSaved = true;
},
playSignal(ringtoneVolume) {
// Initialize the AudioContext if it hasn't been created yet
if (!this.audioCtx) {
this.audioCtx = new (window.AudioContext || window.webkitAudioContext)();
}
const oscillator = this.audioCtx.createOscillator();
oscillator.frequency.setValueAtTime(440, this.audioCtx.currentTime); // Standard A4 note
const gainNode = this.audioCtx.createGain();
gainNode.gain.value = ringtoneVolume; // Set the ringtoneVolume based on the selected value
oscillator.connect(gainNode);
gainNode.connect(this.audioCtx.destination);
oscillator.start();
oscillator.stop(this.audioCtx.currentTime + 0.2);
},
// Use your custom debounce method
debouncedPlayBeep: debounce(function (volume) {
this.playSignal(volume);
triggerSound(volume);
}, {}, 300), // Debounce options and 300ms wait time
},
mounted() {
Expand Down

0 comments on commit ee2eaa9

Please sign in to comment.