AudioSourceSelect.tsx 835 B

12345678910111213141516171819202122232425262728293031323334
  1. import { h } from 'preact'
  2. export interface AudioSourceSelectProps {
  3. currentDeviceId: string
  4. audioSources: MediaDeviceInfo[]
  5. onChangeSource: (value: string) => void
  6. }
  7. export default ({
  8. currentDeviceId,
  9. audioSources,
  10. onChangeSource,
  11. }: AudioSourceSelectProps): JSX.Element => {
  12. return (
  13. <div className="uppy-Audio-videoSource">
  14. <select
  15. className="uppy-u-reset uppy-Audio-audioSource-select"
  16. onChange={(event) => {
  17. onChangeSource(event.target.value)
  18. }}
  19. >
  20. {audioSources.map((audioSource) => (
  21. <option
  22. key={audioSource.deviceId}
  23. value={audioSource.deviceId}
  24. selected={audioSource.deviceId === currentDeviceId}
  25. >
  26. {audioSource.label}
  27. </option>
  28. ))}
  29. </select>
  30. </div>
  31. )
  32. }