From 060046ffe976fd11372d958c83242082a686a0f1 Mon Sep 17 00:00:00 2001 From: torcado Date: Wed, 15 Feb 2023 17:49:22 -0500 Subject: [PATCH] add autoload option, fix rare loading issue --- README.md | 8 ++++++++ index.html | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/README.md b/README.md index ea2348a..d065e07 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,14 @@ And that's it! you can upload the files to your website, or zip them up and uplo `feature` (optional) > If `true`, sets this file as the "featured" track, which will queue up first when loading the page. > Can be either `true` or `false` +> Defaults to `false` + +\ +`autoload` (optional) +> If `true` and `feature` is also `true`, this track will play after loading. +> **NOTE:** this *will not* work in most cases, due to browsers preventing autoplaying audio until the user interacts with the page. This will only be relevant if the player is loaded after user interaction, e.g. when running on itch.io with autoload disabled. +> Can be either `true` or `false` +> Defaults to `false` \ `type` (optional) diff --git a/index.html b/index.html index d911d00..3696b3f 100644 --- a/index.html +++ b/index.html @@ -1114,11 +1114,16 @@ }); loaderEl.addEventListener('canplay', e => { removeLoading(entry, true); + + if(entry.feature && entry.autoplay){ + playerEl.play(); + } }); loaderEl.volume = 0; loaderEl.src = entry.file; entry.started = false; entry.loading = true; + entry.loaderEl = loaderEl; } }); loadEntry(media[mod(featureIndex, media.length)]);