# In-code sound loop?

**URL:** <https://forum.choiceofgames.com/t/in-code-sound-loop/80997>\
**Category:** ChoiceScript Help\
**Tags:** coder\
**Created:** [June 11, 2020, 2:25pm UTC](https://forum.choiceofgames.com/t/in-code-sound-loop/80997 "2020-06-11T14:25:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rin\_Aikishida](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/rin_aikishida/32/119103_2.png) [@Rin\_Aikishida](https://forum.choiceofgames.com/u/Rin_Aikishida)\
**Post date:** [June 11, 2020, 2:25pm UTC](https://forum.choiceofgames.com/t/in-code-sound-loop/80997/1 "2020-06-11T14:25:50Z")

</div>

Ok so, the thing is, I have this audio file of a song that lasts around 3 minutes, but the next song change comes later in the code, which means, there’s a part where everything is just silent and… I don’t want that.  
I have been thinking about looping the file manually using audacity, but that’ll make it heavier and I don’t want to use like a third of the game’s weight for just one single soundtrack.  
Is there anyway to loop it through the code? I thought about maybe doing something like

```
*if sound != song.mp3
 *sound song.mp3
 *else
  *page_break

```

But, aside from _not even working since sound isn’t a variable_, if it worked this couldn’t be put everywhere and even if it could be, it could still lead to moments of silence unless I make every page pretty short so that the checks are almost every 10 seconds if not less (which still would cause silence at some point)

---

<div class="post-metadata">

**Author:** ![cup\_half\_empty](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cup_half_empty/32/273983_2.png) [@cup\_half\_empty](https://forum.choiceofgames.com/u/cup_half_empty)\
**Post date:** [June 11, 2020, 3:21pm UTC](https://forum.choiceofgames.com/t/in-code-sound-loop/80997/2 "2020-06-11T15:21:43Z")

</div>

It’s not possible as far as I know. ChoiceScript lacks thorough support for audio (or any other kind of media, to be honest) except for the very basic.

There was a plugin [once](https://forum.choiceofgames.com/t/unofficial-choicescript-audio-enhanced-plugin/37923), but it’s been discontinued by the creator. And wouldn’t be able to be used anyway if you plan to publish through CoG’s labels.

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [June 11, 2020, 3:39pm UTC](https://forum.choiceofgames.com/t/in-code-sound-loop/80997/3 "2020-06-11T15:39:13Z")

</div>

This isn’t really supported, but you could _try_:

```
*sound confirm.mp3
*script document.getElementsByTagName("audio")[0].setAttribute("loop", true);

```

Note that `*script` is not supported though, and we discourage in-depth JavaScript discussions here. So you’ll be on your own if you’re going down that route.
