Merge pull request #25168 from eska014/html5-autoplay
Deal with Google's HTML5 autoplay policy
This commit is contained in:
commit
bef383985e
3 changed files with 16 additions and 0 deletions
|
@ -146,6 +146,15 @@ void AudioDriverJavaScript::start() {
|
||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioDriverJavaScript::resume() {
|
||||||
|
/* clang-format off */
|
||||||
|
EM_ASM({
|
||||||
|
if (_audioDriver_audioContext.resume)
|
||||||
|
_audioDriver_audioContext.resume();
|
||||||
|
});
|
||||||
|
/* clang-format on */
|
||||||
|
}
|
||||||
|
|
||||||
int AudioDriverJavaScript::get_mix_rate() const {
|
int AudioDriverJavaScript::get_mix_rate() const {
|
||||||
|
|
||||||
/* clang-format off */
|
/* clang-format off */
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
|
|
||||||
virtual Error init();
|
virtual Error init();
|
||||||
virtual void start();
|
virtual void start();
|
||||||
|
void resume();
|
||||||
virtual int get_mix_rate() const;
|
virtual int get_mix_rate() const;
|
||||||
virtual SpeakerMode get_speaker_mode() const;
|
virtual SpeakerMode get_speaker_mode() const;
|
||||||
virtual void lock();
|
virtual void lock();
|
||||||
|
|
|
@ -245,6 +245,8 @@ EM_BOOL OS_JavaScript::keydown_callback(int p_event_type, const EmscriptenKeyboa
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
os->input->parse_input_event(ev);
|
os->input->parse_input_event(ev);
|
||||||
|
// Resume audio context after input in case autoplay was denied.
|
||||||
|
os->audio_driver_javascript.resume();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,6 +337,8 @@ EM_BOOL OS_JavaScript::mouse_button_callback(int p_event_type, const EmscriptenM
|
||||||
ev->set_button_mask(mask);
|
ev->set_button_mask(mask);
|
||||||
|
|
||||||
os->input->parse_input_event(ev);
|
os->input->parse_input_event(ev);
|
||||||
|
// Resume audio context after input in case autoplay was denied.
|
||||||
|
os->audio_driver_javascript.resume();
|
||||||
// Prevent multi-click text selection and wheel-click scrolling anchor.
|
// Prevent multi-click text selection and wheel-click scrolling anchor.
|
||||||
// Context menu is prevented through contextmenu event.
|
// Context menu is prevented through contextmenu event.
|
||||||
return true;
|
return true;
|
||||||
|
@ -663,6 +667,8 @@ EM_BOOL OS_JavaScript::touch_press_callback(int p_event_type, const EmscriptenTo
|
||||||
|
|
||||||
os->input->parse_input_event(ev);
|
os->input->parse_input_event(ev);
|
||||||
}
|
}
|
||||||
|
// Resume audio context after input in case autoplay was denied.
|
||||||
|
os->audio_driver_javascript.resume();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue