audio_system_is_available


描述

This function can be used to check and see if the audio system has been initialised, or if the audio context is running. On all platforms, this function will return true immediately after Game Start when the audio engine is initialised, except on the HTML5 target. On HTML5, the audio context status can change at any time depending on user input, the browser being used, and its version, so this function can be used to check and see if audio can be played or not. If the function returns false (ie: the audio context status is not running), then only unstreamed sounds may play (but it's not guaranteed, and you should assume that no audio can be played), while if it returns true then all audio will play.


语法:

audio_system_is_available();


返回:

Boolean(布尔值)


例如:

if audio_system_is_available()
    {
    if audio_is_paused(global.Music)
        {
        audio_resume_sound(global.Music)
        }
    else
        {
        if !audio_is_playing(global.Music)
            {
            global.Music = audio_play_sound(snd_Music, 0, true);
            }
        }
    }
else
    {
    if audio_is_playing(global.Music)
        {
        audio_pause_sound(global.Music);
        }
    }

The above code will pause/unpause an audio track depending on whether the audio system is initialised and available or not.