Created
June 10, 2022 12:13
-
-
Save kuschanton/182c6f2d3187a4be56690e83ccc0b797 to your computer and use it in GitHub Desktop.
Twilio Flex: code snippet to be used in a Flex Plugin to make browser play ringtone when a task comes in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Flex.Manager.getInstance().workerClient.on('reservationCreated', (reservation: Reservation) => { | |
console.log('reservation', reservation) | |
let mediaId = Flex.AudioPlayerManager.play({ | |
url: 'https://api.twilio.com/cowbell.mp3', | |
repeatable: true, | |
}) | |
reservation.on('accepted', () => Flex.AudioPlayerManager.stop(mediaId)) | |
reservation.on('canceled', () => Flex.AudioPlayerManager.stop(mediaId)) | |
reservation.on('completed', () => Flex.AudioPlayerManager.stop(mediaId)) | |
reservation.on('rejected', () => Flex.AudioPlayerManager.stop(mediaId)) | |
reservation.on('rescinded', () => Flex.AudioPlayerManager.stop(mediaId)) | |
reservation.on('timeout', () => Flex.AudioPlayerManager.stop(mediaId)) | |
reservation.on('wrapup', () => Flex.AudioPlayerManager.stop(mediaId)) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment