• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Import] Playing a song in game

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

What is the standard way to play an imported sound file as looping song?

e.g. suppose I have some sound file. How do I import it--as music or as sound?

Once I made that choice, suppose I want the song to play constantly and suppose it lasts N seconds.

Do I use a timer that plays the song every N seconds (and what native should I use for this?).

I found this very helpful tutorial, but it doesn't say how to do looping correctly for songs: http://www.hiveworkshop.com/forums/...ials-278/how-use-custom-music-your-map-31249/
 
You import music (wav files only) as sounds.

To effectively loop a sound you need some variables.

Set Sound_Var = YourSound
Set SoundLength_Var = length of the song (in seconds)
Set SoundTimer_Var = a simple timer

So when you want the sound to begin playing (and then continue to be looped) make a trigger like this:

  • Events - Your Event
  • Conditions - Your Conditions
  • Actions -
  • Play Sound_Var
  • Start SoundTimer_Var as a one-shot timer that will expire in SoundLength_Var seconds
  • Events - SoundTimer expires
  • Conditions -
  • Actions -
  • Stop Immediately Sound_Var
  • Play Sound_Var
  • Start SoundTimer_Var as a one-shot timer that will expire in SoundLength_Var seconds
Edit:
I wrote MP3 only, but it's wav files only.
 
Level 5
Joined
Jan 27, 2014
Messages
164
There's an easier way to do this.

First, import your sound file.
Go to the Sound Editor. Double click your sound file.
In the 'Options' checkbox, tick 'Looping'.
In the 'Channel' dropmenu, select 'Music'.

Then play your sound file using trigger:
Sound - Play YourSound

It'll loop non stop until you stop it manually using trigger action.


And I believe .mp3 files work as well.
 
There's an easier way to do this.

First, import your sound file.
Go to the Sound Editor. Double click your sound file.
In the 'Options' checkbox, tick 'Looping'.
In the 'Channel' dropmenu, select 'Music'.

Then play your sound file using trigger:
Sound - Play YourSound

It'll loop non stop until you stop it manually using trigger action.


And I believe .mp3 files work as well.
Not recommended for two reasons:
1) it doesn't work in all cases
2) PlaySound is obviously a sound and not music, which means the volume can not be controlled via the music volume slider in game options.
 
Status
Not open for further replies.
Top