adds autoplay option

This commit is contained in:
Ollie Taylor
2023-02-24 14:01:43 +00:00
parent 20fc307099
commit d7d81ce732
4 changed files with 18 additions and 5 deletions
+7 -1
View File
@@ -1,4 +1,5 @@
import {
audio_autoplay,
audio_current_time,
audio_element,
audio_metadata,
@@ -65,8 +66,13 @@ function unmute(type: HandleType = 'set') {
})();
}
function load(src: string) {
type LoadOptions = {
autoplay: boolean;
};
function load(src: string, opts: LoadOptions) {
info('load: ', src);
audio_autoplay.set(opts.autoplay);
audio_src.set(src);
return audio_element.subscribe((el) => {
if (!el) return warn('no audio element');