# How to check for sound output device

**URL:** <https://forum.inductiveautomation.com/t/how-to-check-for-sound-output-device/26482>\
**Category:** Ignition\
**Created:** [July 11, 2019, 4:02pm UTC](https://forum.inductiveautomation.com/t/how-to-check-for-sound-output-device/26482 "2019-07-11T16:02:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [July 11, 2019, 4:02pm UTC](https://forum.inductiveautomation.com/t/how-to-check-for-sound-output-device/26482/1 "2019-07-11T16:02:30Z")

</div>

When the audio player attempts to play a sound on a client with no audio output device, Ignition throws this error:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/8b416e43b8e4bb0ae1836049f145a5dd05ecc91c.png)

> Details: java.lang.IllegalArgumentException: No line matching interface Clip supporting format PCM\_SIGNED 22050.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian, and buffers of 80764 to 80764 bytes is supported...

What would be a good way to check whether an output device is available ahead of time to disable sound playback and avoid this error message?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [July 11, 2019, 7:57pm UTC](https://forum.inductiveautomation.com/t/how-to-check-for-sound-output-device/26482/2 "2019-07-11T19:57:30Z")

</div>

I don’t have anything here without audio, so I can’t test it, but this should be pretty quick and dirty:

```python
def soundCardExists():
	from javax.sound.sampled import AudioSystem
	try:
		l = AudioSystem.getSourceDataLine(None)
		return True
	except:
		return False

soundCardExists()

```

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [July 13, 2019, 12:53am UTC](https://forum.inductiveautomation.com/t/how-to-check-for-sound-output-device/26482/3 "2019-07-13T00:53:30Z")

</div>

Thanks @JordanCClark, your code works as expected on a device without audio (as well as on devices with it). My initial post was incorrect in that the error is generated when the sound player component _loads_ `soundData`–_not_ when it tries to play it. A binding like the one below on ‘soundData’ avoids the error. A function like yours sets the client tag in a client startup script and sound bytes are stored in a tag.

```java
// Clear sound data on clients with no sound output device to avoid errors.
if(!{[Client]isSoundOutputDeviceAvailable}, None, {Ignition/sounds}[3,1])

```

---

<div class="post-metadata">

**Author:** ![brandon1](https://avatars.discourse-cdn.com/v4/letter/b/ea666f/32.png) [@brandon1](https://forum.inductiveautomation.com/u/brandon1)\
**Post date:** [December 8, 2020, 2:04pm UTC](https://forum.inductiveautomation.com/t/how-to-check-for-sound-output-device/26482/4 "2020-12-08T14:04:11Z")

</div>

Can you tell me how you stored the sound bytes in the dataset?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 8, 2020, 3:49pm UTC](https://forum.inductiveautomation.com/t/how-to-check-for-sound-output-device/26482/5 "2020-12-08T15:49:30Z")

</div>

It’s been a while, but I believe I used the browse button on soundData property of the sound player component to load a sound into it and then copied the soundData string that showed up in that property to the dataset.
