# Pause Music on List Method! / QUESTION / SCRIPT

**URL:** <https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785>\
**Category:** Unity\
**Tags:** unity, csharp\
**Created:** [October 19, 2023, 7:17am UTC](https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785 "2023-10-19T07:17:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![iAgharta](https://avatars.discourse-cdn.com/v4/letter/i/ea666f/32.png) [@iAgharta](https://qa.fmod.com/u/iAgharta)\
**Post date:** [October 19, 2023, 7:17am UTC](https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785/1 "2023-10-19T07:17:14Z")

</div>

Hi folks i have a question i would like to share with you:

with your help I´ve been able to create an script to play some slave GameObjects with fmod emitter inside into a master GameObject which contains all the slaves inside…

this is what i mean:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/0/08c98a6084cfa646c967394145dd8d2be94a5aee.png)

the idea is that everytime the scene with the script inside load, an event from the list you see in the image is going to play, so far is working but im having problems adding the pause method in this script:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/8/8b29006f6e20ee4156aef3c219e3ad4a2c7b461e.png)

in the internet ive see multiple methods to do it but for my specific idea no method is working!!

could u solve this riddle? i just want to been able to pause the music when the pause button is pressed…

an idea from youtube says that we could use snapshots and a parameter to trigger sometype of filter, if that could work, how i could been able to call the snapshot in the script i just share with you guys??? or the parameter trigger could go inside the pause button gameObject in Unity to trigger the parameter???

HOPE U GUYS UNDERSTAND MY IDEA AND MY GRAMMAR, def english is not my primary languageD:

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [October 23, 2023, 5:13am UTC](https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785/2 "2023-10-23T05:13:01Z")

</div>

Hi,

You could use the `EventInstance::setPaused` function ([FMOD Engine | Studio API Reference - Event Instance](https://fmod.com/docs/2.02/api/studio-api-eventinstance.html#studio_eventinstance_setpaused)).

1. With the `trackToPlay` int we know which event we need to pause so we will use that to choose the emitter in our list
2. With the emitter in our list we can retrieve the `EventInstance` with `tracks[trackToPlay].EventInstance` ([Unity Integration | Scripting API Reference - StudioEventEmitter](https://fmod.com/docs/2.02/unity/api-studioeventemitter.html#studioeventemitter_eventinstance))
3. Now with the `EventInstance` you can call `setPaused()`

I would suggest creating two public functions in your class `PauseCurrentTrack()` and `ResumeCurrentTrack()`. With these two functions, you can pause a start the current track in the list.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![iAgharta](https://avatars.discourse-cdn.com/v4/letter/i/ea666f/32.png) [@iAgharta](https://qa.fmod.com/u/iAgharta)\
**Post date:** [November 8, 2023, 11:02pm UTC](https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785/3 "2023-11-08T23:02:58Z")

</div>

bro i love you for answer but i dont know script ☹ i already try everything to make your reply work but my abilities are not that good, if you could explain a little more further or put the code lines based on my image in the post here i would aprecciate so much ☹

sorry for my grammar english is not my first language hope i explained well

---

<div class="post-metadata">

**Author:** ![iAgharta](https://avatars.discourse-cdn.com/v4/letter/i/ea666f/32.png) [@iAgharta](https://qa.fmod.com/u/iAgharta)\
**Post date:** [November 9, 2023, 4:35am UTC](https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785/5 "2023-11-09T04:35:32Z")

</div>

so far i gat this

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/4/41656ab197a094cf5ee96c6b4775a774e371b2cd.png)

i dont know how to reference the list in the methods D:

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [November 10, 2023, 1:53am UTC](https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785/6 "2023-11-10T01:53:46Z")

</div>

Hi,

Please find attached a script that has two public functions `PuaseCurrentTrack()` and `ResumeCurrentTrack()`. Hopefully, this is the functionality you are looking for.  
[PlayMusic.txt](https://qa.fmod.com/uploads/short-url/Agbm3aEBqOnsEnIX5P6QMy5kfvI.txt) (933 Bytes)

---

<div class="post-metadata">

**Author:** ![iAgharta](https://avatars.discourse-cdn.com/v4/letter/i/ea666f/32.png) [@iAgharta](https://qa.fmod.com/u/iAgharta)\
**Post date:** [November 10, 2023, 3:35am UTC](https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785/7 "2023-11-10T03:35:26Z")

</div>

dudeeeeeee thank you so much man I know is not your work do mine but this really help me out; the doc you send does not work entirely but it sure give me the answer i need; with the FMOD. Result i was able to reference my list in the methods then in the general script of the game i call the instance from the script who has the methods with the FMOD.Results inside.

THANK YOU VERY MUCH CONNOR I LOVE YOU!!!

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [November 10, 2023, 4:04am UTC](https://qa.fmod.com/t/pause-music-on-list-method-question-script/20785/8 "2023-11-10T04:04:00Z")

</div>

Hi,

Happy to help!
