# How do I play Audio in Java?

**URL:** https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932
**Category:** Audio & Video
**Tags:** Scripting
**Created:** [November 3, 2015, 11:52am UTC](https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932 "2015-11-03T11:52:03Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![SD2020](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/sd2020/32/184297_2.png) [@SD2020](https://discussions.unity.com/u/SD2020)
#### Post date: [November 3, 2015, 11:52am UTC](https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932/1 "2015-11-03T11:52:03Z")

</div>

I have been doing some college work and i am trying to make it so when i click to shoot it plays a sound! I have the “var ShootSound : AudioSource” i just need the line of code to trigger the sound to play.

Can someone please help me!

Thanks.

-SD2020\_

---

<div class="post-metadata">

### Author: ![LeftyRighty](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@LeftyRighty](https://discussions.unity.com/u/LeftyRighty)
#### Post date: [November 3, 2015, 11:56am UTC](https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932/2 "2015-11-03T11:56:33Z")

</div>

> **[Learn game development w/ Unity | Courses & tutorials in game design, VR,...](https://learn.unity.com/search?k=%5B%22q%3AAudio%22%5D)**
>
> Free tutorials, courses, and guided pathways for mastering real-time 3D development skills to make video games, VR, AR, and more.

Unity doesn’t use “Java”, thats entirely different. Unity supports a version of javascript, which isn’t the same as javascript used elsewhere, usually the term “unityscript” is used to help disambiguate.

---

<div class="post-metadata">

### Author: ![SD2020](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/sd2020/32/184297_2.png) [@SD2020](https://discussions.unity.com/u/SD2020)
#### Post date: [November 3, 2015, 1:21pm UTC](https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932/3 "2015-11-03T13:21:46Z")

</div>

> [@LeftyRighty](#):
>
> [https://unity3d.com/learn/tutorials/topics/audio](https://unity3d.com/learn/tutorials/topics/audio)
> 
> Unity doesn’t use “Java”, thats entirely different. Unity supports a version of javascript, which isn’t the same as javascript used elsewhere, usually the term “unityscript” is used to help disambiguate.

I am aware, but i have done audio in javascript in unity before but confused if it was changed in unity 5. Would you know the line of code i would use to play the audio?

---

<div class="post-metadata">

### Author: ![LeftyRighty](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@LeftyRighty](https://discussions.unity.com/u/LeftyRighty)
#### Post date: [November 3, 2015, 1:27pm UTC](https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932/4 "2015-11-03T13:27:58Z")

</div>

follow link, watch the tutorials… there is one on scripting and one that covers the changes that came in unity 5, they explain it far more succinctly than a forum will.

---

<div class="post-metadata">

### Author: ![passerbycmc](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/passerbycmc/32/419751_2.png) [@passerbycmc](https://discussions.unity.com/u/passerbycmc)
#### Post date: [November 3, 2015, 1:29pm UTC](https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932/5 "2015-11-03T13:29:46Z")

</div>

.play() on reference to a audio clip

---

<div class="post-metadata">

### Author: ![LeftyRighty](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@LeftyRighty](https://discussions.unity.com/u/LeftyRighty)
#### Post date: [November 3, 2015, 1:33pm UTC](https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932/6 "2015-11-03T13:33:39Z")

</div>

> [@passerbycmc](#):
>
> .play() on reference to a audio clip

audioclips don’t have a play function… audiosources do. Setting the audiosource to play the correct clip is covered in the tutorials.

---

<div class="post-metadata">

### Author: ![SD2020](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/sd2020/32/184297_2.png) [@SD2020](https://discussions.unity.com/u/SD2020)
#### Post date: [November 3, 2015, 2:05pm UTC](https://discussions.unity.com/t/how-do-i-play-audio-in-java/603932/7 "2015-11-03T14:05:14Z")

</div>

> [@LeftyRighty](#):
>
> audioclips don’t have a play function… audiosources do. Setting the audiosource to play the correct clip is covered in the tutorials.

Could you please give me an idea of what it would look like?
