Added option to automatically play media upon embed.

This commit is contained in:
flash 2024-05-16 20:16:32 +00:00
parent f4b43290bb
commit 5b35595fea
3 changed files with 18 additions and 3 deletions

View file

@ -94,6 +94,7 @@ window.Umi = { UI: {} };
settings.define('expandTextBox').default(false).create(); settings.define('expandTextBox').default(false).create();
settings.define('eepromAutoInsert').default(true).create(); settings.define('eepromAutoInsert').default(true).create();
settings.define('autoEmbedV1').default(false).create(); settings.define('autoEmbedV1').default(false).create();
settings.define('autoEmbedPlay').default(false).create();
settings.define('soundEnable').default(true).critical().create(); settings.define('soundEnable').default(true).critical().create();
settings.define('soundPack').default('').create(); settings.define('soundPack').default('').create();
settings.define('soundVolume').default(80).min(0).max(100).create(); settings.define('soundVolume').default(80).min(0).max(100).create();

View file

@ -262,7 +262,8 @@ Umi.Parsing = (function() {
element.dataset.embed = '1'; element.dataset.embed = '1';
element.textContent = 'Remove'; element.textContent = 'Remove';
container.textContent = ''; container.textContent = '';
container.appendChild($e({
let media = $e({
tag: 'audio', tag: 'audio',
attrs: { attrs: {
src: url, src: url,
@ -270,9 +271,13 @@ Umi.Parsing = (function() {
onloadedmetadata: () => { onloadedmetadata: () => {
if(mami.settings.get('autoScroll')) if(mami.settings.get('autoScroll'))
container.scrollIntoView({ inline: 'end' }); container.scrollIntoView({ inline: 'end' });
if(mami.settings.get('autoEmbedPlay'))
media.play();
}, },
}, },
})); });
container.appendChild(media);
} }
}; };
const toggleVideo = function(element) { const toggleVideo = function(element) {
@ -300,7 +305,7 @@ Umi.Parsing = (function() {
element.dataset.embed = '1'; element.dataset.embed = '1';
element.textContent = 'Remove'; element.textContent = 'Remove';
let html = $e({ let media = $e({
tag: 'video', tag: 'video',
attrs: { attrs: {
src: url, src: url,
@ -312,10 +317,14 @@ Umi.Parsing = (function() {
onloadedmetadata: () => { onloadedmetadata: () => {
if(mami.settings.get('autoScroll')) if(mami.settings.get('autoScroll'))
container.scrollIntoView({ inline: 'end' }); container.scrollIntoView({ inline: 'end' });
if(mami.settings.get('autoEmbedPlay'))
media.play();
}, },
}, },
}); });
let html = media;
if(mami.settings.get('motivationalVideos')) if(mami.settings.get('motivationalVideos'))
html = motivFrame( html = motivFrame(
extractMotiv(element), extractMotiv(element),

View file

@ -74,6 +74,11 @@ Umi.UI.Settings = (function() {
title: 'Auto-embed media', title: 'Auto-embed media',
type: 'checkbox', type: 'checkbox',
}, },
{
name: 'autoEmbedPlay',
title: 'Auto-play media',
type: 'checkbox',
},
], ],
}, },
{ {