JMW
Aspiring Addon Developer
Is it possible (if so how) to program the playing of an mp3 from a .dll
Want it to start playing after a set period of time - say 2 mins.
Want it to start playing after a set period of time - say 2 mins.
--link to player or exit if it doesn't exist
require("proAudioRt")
if not proAudio.create() then os.exit(1) end
sound = proAudio.sampleFromFile("Sound/Ogg/yoursound.ogg")--load the sound.
--yoursound is the name of the ogg file. Don't forget the extension.
sim_t = oapi.get_simtime()
play_t = 120 --number of seconds you want the file to start playing after scenario start
duration = proAudio.sampleProperties(sound) --audio file duration in seconds
play = 0 --player counter
while sim_t < (duration+play_t) do
sim_t = oapi.get_simtime()
if sim_t > play_t then
play = play +1
if play == 1 then --play the sound
proAudio.soundPlay(sound)
end
if play > 2 then --stop the counter
play = 2
end
end
proc.skip()
if sim_t > (duration + play_t) then --if the simtime is > sound+wait close the player
proAudio.destroy()
end
end --close the script
Script playsound


require("proAudioRt")
if not proAudio.create() then os.exit(1) end --get the player or exit if it doesn't exist
sound1 = proAudio.sampleFromFile("Sound/Ogg/yoursound1.ogg")
sound2 = proAudio.sampleFromFile("Sound/Ogg/yoursound2.ogg")
--load all the sounds at the start of the scenario
sim_t = oapi.get_simtime()
play_t1 = 120 -- number of seconds in simulation to play sound1
play_t2 = 140 -- number of seconds in simulation to play sound2
play1 = 0 --counter for sound1
play2 = 0 --counter for sound2
--[[in the next variable, replace x with the biggest value that follows this rule: (sound duration + play_t)
Example:
Lets say sound1 is 300 seconds long and it starts at 120. The total time for that is 420
Lets say sound2 is 60 seconds long and it starts at 140. The total time for that is 200
You must use the biggest value (420) for the total_t]]--
total_t = x --replace x with the longest total_t
while sim_t < total_t do
sim_t = oapi.get_simtime()
if sim_t > play_t1 then
play1 = play1 +1
if play1 == 1 then
proAudio.soundPlay(sound1)
end
if play1 > 2 then
play1 = 2
end
end
if sim_t > play_t2 then
play2 = play2 +1
if play2 == 1 then
proAudio.soundPlay(sound2)
end
if play2 > 2 then
play2 = 2
end
end
proc.skip()
if sim_t > total_t then
proAudio.destroy()
end
end
:tiphat:And finally, Orbiter Sound has nothing to help for lua scripts.
That maybe good for interactive tutorials or for challenges design ! Like "Ermagherd, you are too slow ! And look at all this burnt fuel !" :lol:
Have you seen my recent challenges?
I am only mentioning them because in addition to the usual script I am using the proteaAudio to play various sounds when certain conditions have been met. (either failures or successes).