メニュー

Expand
ページを評価:

Twilio Client JS SDK: AudioOutputCollection

You’re viewing the 1.X version of the Voice JavaScript SDK (formerly called Twilio Client). Click here for information on how to migrate to the 2.X version.

Both speakerDevices and ringtoneDevices properties of Twilio.Device.audio are instances of AudioOutputCollection . These AudioOutputCollections represent active audio devices, and can be updated to redirect speaker and ringtone sounds to different devices in realtime.

メソッドの参照

The following is a list of methods available on AudioOutputCollection instances:

audioOutputCollection.get()

Get a Set containing MediaDeviceInfo objects representing the active devices in the collection.

audioOutputCollection.set( deviceId | deviceIds )

Replace the active devices in the collection by passing one or more device IDs. Returns a Promise, which is fulfilled if the device(s) were set successfully and rejected if:

  • Output selection is not supported by the browser or
  • A specified deviceId wasn’t found or
  • No deviceIds were specified

audioOutputCollection.test( soundUrl )

Test the active devices by playing a sound through them. Optionally, a URL can be passed to play a custom test sound. Returns a Promise, which is fulfilled if the devices were set successfully and rejected if:

  • Output selection is not supported by the browser or
  • There are no active devices or
  • Client detects one or more devices failed to play

Browser Support

Audio selection requires the setSinkId functionality which, at the time of writing, is only supported in Chrome 49.0 and above; as Firefox and Edge add support for these APIs, twilio.js will be able to automatically make use of them.

If unsupported, the get method will return an empty Set , whereas the set and test methods will return a rejected Promise.

ページを評価:

ヘルプが必要ですか?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Community Forums or browsing the Twilio tag on Stack Overflow.

        
        
        

        フィードバックくださりありがとうございます!

        We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        Refer us and get $10 in 3 simple steps!

        ステップ1

        Get link

        Get a free personal referral link here

        ステップ2:

        Give $10

        Your user signs up and upgrade using link

        ステップ3

        Get $10

        1,250 free SMSes
        OR 1,000 free voice mins
        OR 12,000 chats
        OR more