Author Topic: Need help looping audio while on a vehicle.  (Read 1628 times)

Cap

I'm not sure why it doesn't work. I have the sound data block which works when used in states (The code is just an example.)

Code: [Select]
datablock AudioProfile(musicIdelSound)
{
   filename    = "./sound/music.ogg";
   description = AudioCloseLooping3d;
   preload = true;
};

But getting audio to start in a function doesn't work, which also makes me unsure if the stopping code works.

I have
Code: [Select]
%client.player.playAudio(0, musicIdelSound); in the start function, and
Code: [Select]
%client.player.stopAudio(0, musicIdelSound); in the end function, and that doesn't work. This is going to be used in a vehicle type item. It might help to think of the skis with this problem.

First of all, it's "idle", not "idel".

Second, make sure your script is enabled as an Add-On.

Start a server.

Open the console, and type "findLocalClient().Player.playAudio(0,musicIdleSound);" without the quotes and press enter.

If the audio doesn't start playing (but you can still hear music from music bricks after making one), either

A: Your sound file is in the wrong place.
B: Your sound file has 2 or more channels (stereo / surround) instead of a single channel (mono).

Personally, I'd guess you goofed on B.

Cap

First of all, it's "idle", not "idel".

Second, make sure your script is enabled as an Add-On.

Start a server.

Open the console, and type "findLocalClient().Player.playAudio(0,musicIdleSound);" without the quotes and press enter.

If the audio doesn't start playing (but you can still hear music from music bricks after making one), either

A: Your sound file is in the wrong place.
B: Your sound file has 2 or more channels (stereo / surround) instead of a single channel (mono).

Personally, I'd guess you goofed on B.

The item itself works, the audio is also mono and works in blockland. I wanted the audio to start when the vehicle was mounted, and end when unmounted. The audio file is in the correct place, C:\Program Files\Blockland\Add-Ons\Sound\

%object.stopAudio() only has one parameter - the slot number.

Try this:
Code: [Select]
%object.stopAudio(0);

Cap

Thanks!

Code: [Select]
%obj.playAudio(0,musicIdleSound); and
Code: [Select]
%player.stopAudio(0); worked.
« Last Edit: January 17, 2008, 04:34:05 PM by Cap »


The audio slots are the same as the Thread slots, so be careful (Atleast I think they are, I can't be bothered to test).