2022-05-08 09:25:09 +02:00
|
|
|
-- name: Audio Test
|
2022-05-08 13:32:18 +02:00
|
|
|
-- description: Testing out the custom audio system
|
2022-05-08 09:25:09 +02:00
|
|
|
-- incompatible:
|
|
|
|
|
2022-05-08 13:32:18 +02:00
|
|
|
audioStream = nil;
|
|
|
|
audioSample = nil;
|
2022-05-08 09:25:09 +02:00
|
|
|
|
2022-05-08 13:32:18 +02:00
|
|
|
function on_stream_play(msg)
|
|
|
|
if(msg == "load") then
|
|
|
|
audioStream = audio_stream_load("music.mp3")
|
|
|
|
audio_stream_set_looping(audioStream, true)
|
|
|
|
djui_chat_message_create("audio audioStream:" .. tostring(audioStream));
|
2022-05-08 09:25:09 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if(msg == "play") then
|
2022-05-08 13:32:18 +02:00
|
|
|
audio_stream_play(audioStream, true, 1);
|
2022-05-08 09:25:09 +02:00
|
|
|
djui_chat_message_create("playing audio");
|
|
|
|
end
|
|
|
|
|
|
|
|
if(msg == "resume") then
|
2022-05-08 13:32:18 +02:00
|
|
|
audio_stream_play(audioStream, false, 1);
|
2022-05-08 09:25:09 +02:00
|
|
|
djui_chat_message_create("resuming audio");
|
|
|
|
end
|
|
|
|
|
|
|
|
if(msg == "pause") then
|
2022-05-08 13:32:18 +02:00
|
|
|
audio_stream_pause(audioStream);
|
2022-05-08 09:25:09 +02:00
|
|
|
djui_chat_message_create("pausing audio");
|
|
|
|
end
|
|
|
|
|
|
|
|
if(msg == "stop") then
|
2022-05-08 13:32:18 +02:00
|
|
|
audio_stream_stop(audioStream);
|
2022-05-08 09:25:09 +02:00
|
|
|
djui_chat_message_create("stopping audio");
|
|
|
|
end
|
|
|
|
|
|
|
|
if(msg == "destroy") then
|
2022-05-08 13:32:18 +02:00
|
|
|
audio_stream_destroy(audioStream);
|
2022-05-08 09:25:09 +02:00
|
|
|
djui_chat_message_create("destroyed audio");
|
|
|
|
end
|
|
|
|
|
|
|
|
if(msg == "getpos") then
|
2022-05-08 13:32:18 +02:00
|
|
|
djui_chat_message_create("pos: " .. tostring(audio_stream_get_position(audioStream)));
|
2022-05-08 09:25:09 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return true;
|
|
|
|
end
|
|
|
|
|
|
|
|
function on_sample_play(msg)
|
2022-05-08 13:32:18 +02:00
|
|
|
if(msg == "load") then
|
|
|
|
audioSample = audio_sample_load("sample.mp3");
|
2022-05-08 09:25:09 +02:00
|
|
|
|
2022-05-08 13:32:18 +02:00
|
|
|
djui_chat_message_create("audio audioStream:" .. tostring(audioSample));
|
2022-05-08 09:25:09 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
end
|
|
|
|
|
2022-05-08 13:32:18 +02:00
|
|
|
audio_sample_play(audioSample, gMarioStates[0].pos, 1);
|
2022-05-08 09:25:09 +02:00
|
|
|
return true;
|
|
|
|
end
|
|
|
|
|
2022-05-08 13:32:18 +02:00
|
|
|
hook_chat_command('stream', "[load|play|resume|pause|stop|destroy|getpos]", on_stream_play)
|
|
|
|
hook_chat_command('sample', "[load|play]", on_sample_play)
|