diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml
index 86dfe4a..54137da 100644
--- a/.gitea/workflows/release.yml
+++ b/.gitea/workflows/release.yml
@@ -48,7 +48,20 @@ jobs:
- name: Compute version
id: ver
- run: echo "version=$(date -u +'%Y.%m.%d-%H%M')" >> "$GITHUB_OUTPUT"
+ run: |
+ # Date-based version to the minute. Two pushes in the same minute would collide on the tag,
+ # so keep moving to the next minute until the tag is unused (format stays YYYY.MM.DD-HHMM).
+ git fetch --tags --quiet origin || true
+ TS=$(date -u +%s)
+ while true; do
+ V=$(date -u -d "@$TS" +'%Y.%m.%d-%H%M')
+ if git rev-parse -q --verify "refs/tags/$V" >/dev/null || git ls-remote --exit-code --tags origin "refs/tags/$V" >/dev/null 2>&1; then
+ TS=$((TS + 60))
+ else
+ break
+ fi
+ done
+ echo "version=$V" >> "$GITHUB_OUTPUT"
- name: Generate release notes
id: notes
diff --git a/assets/admin/alerts.css b/assets/admin/alerts.css
new file mode 100644
index 0000000..b648a87
--- /dev/null
+++ b/assets/admin/alerts.css
@@ -0,0 +1,13 @@
+.sga-help{list-style:disc;margin-left:1.4em}
+.sga-media{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
+.sga-media-name{font-weight:600;overflow-wrap:anywhere}
+.sga-media-warn{flex-basis:100%;margin:0;color:#996800}
+.sga-media-warn:empty{display:none}
+.sga-form input[type=range]{vertical-align:middle;width:220px;max-width:100%}
+.sga-stage{min-height:140px;display:flex;align-items:flex-end;justify-content:center;padding:16px;background:repeating-conic-gradient(#2b2b33 0 25%,#34343d 0 50%) 0 0/20px 20px;border-radius:6px;font-size:18px;color:#fff;line-height:1.2}
+.sga-alert{width:100%;max-width:560px;text-align:center;background:rgba(0,0,0,.45);border:2px solid #7c5cff;border-radius:12px;padding:10px 14px}
+.sga-alert-media{display:flex;justify-content:center;margin-bottom:6px}
+.sga-alert-media img,.sga-alert-media video{display:block;max-width:100%;max-height:260px;object-fit:contain;border-radius:6px}
+.sga-alert-head{font-weight:800;font-size:1.2em}
+.sga-alert-head b{color:#22d3ee}
+.sga-idle{color:#bbb;font-size:14px;align-self:center}
diff --git a/assets/admin/alerts.js b/assets/admin/alerts.js
new file mode 100644
index 0000000..9497a97
--- /dev/null
+++ b/assets/admin/alerts.js
@@ -0,0 +1,150 @@
+/* StreamGoals alert editor: Media Library pickers (wp.media) and a live preview that mirrors the overlay. */
+( function () {
+ 'use strict';
+ var form = document.querySelector( '.sga-form' );
+ var dataEl = document.getElementById( 'sga-data' );
+ var stage = document.getElementById( 'sga-stage' );
+ var playBtn = document.getElementById( 'sga-play' );
+ if ( ! form || ! dataEl || ! stage || ! playBtn ) { return; }
+ var cfg = { currency: 'USD', exp: 2, rewards: [], videoCap: 30000, warnBytes: 26214400, allowed: {} };
+ try { cfg = JSON.parse( dataEl.textContent ); } catch ( e ) { /* defaults */ }
+ var timers = [], media = [];
+
+ function el( tag, cls, text ) {
+ var e = document.createElement( tag );
+ if ( cls ) { e.className = cls; }
+ if ( text != null ) { e.textContent = text; }
+ return e;
+ }
+
+ /* ---- Media Library pickers ---- */
+ Array.prototype.forEach.call( form.querySelectorAll( '.sga-media' ), function ( box ) {
+ var input = box.querySelector( 'input[type=hidden]' );
+ var nameEl = box.querySelector( '.sga-media-name' );
+ var warnEl = box.querySelector( '.sga-media-warn' );
+ var kind = box.getAttribute( 'data-kind' );
+ var frame = null;
+
+ function set( id, url, mime, name, size ) {
+ input.value = String( id || 0 );
+ input.setAttribute( 'data-url', url || '' );
+ input.setAttribute( 'data-mime', mime || '' );
+ nameEl.textContent = id ? name : 'Nothing chosen';
+ var msg = '';
+ if ( id && size > cfg.warnBytes ) {
+ msg = 'This file is over 25 MB. Big files load slowly' + ( /^video\//.test( mime ) ? ' and large videos can make OBS stutter. A short, compressed clip is much better.' : '.' );
+ }
+ warnEl.textContent = msg;
+ input.dispatchEvent( new Event( 'change', { bubbles: true } ) );
+ }
+ function accepts( mime ) {
+ var k = cfg.allowed[ String( mime ).toLowerCase() ];
+ return kind === 'sound' ? k === 'audio' : ( k === 'image' || k === 'video' );
+ }
+ box.querySelector( '.sga-pick' ).addEventListener( 'click', function () {
+ if ( ! window.wp || ! wp.media ) { nameEl.textContent = 'The Media Library could not be loaded. Reload the page.'; return; }
+ if ( ! frame ) {
+ frame = wp.media( {
+ title: kind === 'sound' ? 'Choose a sound' : 'Choose a picture, GIF or video',
+ button: { text: 'Use this file' },
+ library: { type: kind === 'sound' ? [ 'audio' ] : [ 'image', 'video' ] },
+ multiple: false
+ } );
+ frame.on( 'select', function () {
+ var a = frame.state().get( 'selection' ).first().toJSON();
+ if ( ! accepts( a.mime ) ) {
+ warnEl.textContent = 'That file type is not allowed (' + a.mime + '). ' + ( kind === 'sound' ? 'Use MP3, OGG or WAV.' : 'Use PNG, JPEG, GIF, WebP, MP4 or WebM.' );
+ return;
+ }
+ set( a.id, a.url, a.mime, a.filename || a.title || ( 'File ' + a.id ), a.filesizeInBytes || 0 );
+ } );
+ }
+ frame.open();
+ } );
+ box.querySelector( '.sga-clear' ).addEventListener( 'click', function () { set( 0, '', '', '', 0 ); } );
+ } );
+
+ var vol = form.elements.volume, volOut = document.getElementById( 'sga_volume_out' );
+ if ( vol && volOut ) { vol.addEventListener( 'input', function () { volOut.textContent = vol.value; } ); }
+
+ /* ---- preview ---- */
+ function toMinor( raw ) {
+ var s = String( raw == null ? '' : raw ).replace( /[,\s$€£¥]/g, '' );
+ var m = /^(\d+)(?:\.(\d+))?$/.exec( s );
+ if ( ! m ) { return null; }
+ var frac = m[ 2 ] || '';
+ if ( frac.length > cfg.exp ) { return null; }
+ while ( frac.length < cfg.exp ) { frac += '0'; }
+ return parseInt( m[ 1 ] + frac, 10 );
+ }
+ function money( minor ) {
+ var s = String( minor );
+ if ( cfg.exp === 0 ) { return cfg.currency + ' ' + s; }
+ while ( s.length <= cfg.exp ) { s = '0' + s; }
+ return cfg.currency + ' ' + s.slice( 0, -cfg.exp ) + '.' + s.slice( -cfg.exp );
+ }
+ function clean( s ) { return String( s ).replace( /<[^>]*>/g, '' ).replace( /[<>\u0000-\u001f\u007f]/g, ' ' ).replace( /\s+/g, ' ' ).trim(); }
+ function render( tpl, vals ) {
+ var t = clean( tpl );
+ if ( ! t ) { return ''; }
+ return t.replace( /\{([A-Za-z_]{1,20})\}/g, function ( m, k ) { return vals[ k.toLowerCase() ] || ''; } ).replace( /\s+/g, ' ' ).trim().slice( 0, 200 );
+ }
+ function stop() {
+ timers.forEach( clearTimeout ); timers = [];
+ media.forEach( function ( m ) { try { m.pause(); } catch ( e ) { /* ignore */ } } ); media = [];
+ }
+ function inp( name ) { return form.querySelector( '[name="' + name + '"]' ); }
+
+ function play() {
+ stop();
+ stage.textContent = '';
+ var vis = inp( 'visual_id' ), snd = inp( 'sound_id' );
+ var visUrl = vis.value !== '0' ? vis.getAttribute( 'data-url' ) : '', visMime = vis.getAttribute( 'data-mime' ) || '';
+ var sndUrl = snd.value !== '0' ? snd.getAttribute( 'data-url' ) : '';
+ var volume = Math.max( 0, Math.min( 100, parseInt( form.elements.volume.value, 10 ) || 0 ) ) / 100;
+ var dur = Math.max( 1, Math.min( 60, parseFloat( form.elements.duration.value ) || 6 ) ) * 1000;
+ var trig = form.querySelector( 'input[name="trigger_type"]:checked' );
+ var amt = trig && trig.value === 'amount' ? toMinor( form.elements.amount.value ) : null;
+ var rewardSel = form.elements.action_id;
+ var reward = rewardSel && rewardSel.value !== '0' && rewardSel.selectedIndex > 0 ? rewardSel.options[ rewardSel.selectedIndex ].text.replace( / \(turned off\)$/, '' ) : 'Your reward';
+ var vals = { name: 'Alex', amount: money( amt || 500 ), reward: reward };
+ var msg = render( form.elements.message.value, vals );
+
+ var card = el( 'div', 'sga-alert' );
+ var isVideo = /^video\//.test( visMime ), video = null;
+ if ( visUrl ) {
+ var box = el( 'div', 'sga-alert-media' );
+ if ( isVideo ) {
+ video = document.createElement( 'video' );
+ video.playsInline = true; video.setAttribute( 'playsinline', '' );
+ video.muted = !! sndUrl || volume === 0; video.volume = volume;
+ video.src = visUrl; box.appendChild( video );
+ } else {
+ var img = new Image(); img.alt = ''; img.src = visUrl; box.appendChild( img );
+ }
+ card.appendChild( box );
+ }
+ var head = el( 'div', 'sga-alert-head' );
+ if ( msg ) { head.textContent = msg; }
+ else { head.appendChild( el( 'b', null, vals.name ) ); head.appendChild( document.createTextNode( ' donated ' ) ); head.appendChild( el( 'b', null, vals.amount ) ); }
+ card.appendChild( head );
+ stage.appendChild( card );
+
+ if ( sndUrl ) {
+ var au = new Audio( sndUrl ); au.volume = volume; media.push( au );
+ var p = au.play(); if ( p && p.catch ) { p.catch( function () { head.appendChild( el( 'div', 'sga-idle', 'Sound was blocked by the browser.' ) ); } ); }
+ }
+ var end = function () { stop(); stage.textContent = ''; stage.appendChild( el( 'span', 'sga-idle', 'Preview finished.' ) ); };
+ if ( video ) {
+ media.push( video );
+ video.onended = end;
+ var vp = video.play();
+ if ( vp && vp.catch ) { vp.catch( function () { video.muted = true; var again = video.play(); if ( again && again.catch ) { again.catch( function () {} ); } } ); }
+ timers.push( setTimeout( end, cfg.videoCap ) );
+ } else {
+ timers.push( setTimeout( end, dur ) );
+ }
+ }
+ playBtn.addEventListener( 'click', play );
+ stage.appendChild( el( 'span', 'sga-idle', 'Press "Play preview".' ) );
+}() );
diff --git a/assets/overlay/overlay.css b/assets/overlay/overlay.css
index 24e7f94..1e88fb2 100644
--- a/assets/overlay/overlay.css
+++ b/assets/overlay/overlay.css
@@ -24,6 +24,8 @@ body.sg-offline #sg-root{opacity:.6}
.sg-w-alerts #sg-root{align-items:flex-end}
.sg-alert{width:100%;text-align:center;background:var(--sg-bg);border:.1em solid var(--sg-accent);border-radius:.7em;padding:.6em .9em;animation:sg-in .6s cubic-bezier(.22,1,.36,1) both}
.sg-alert.sg-out{animation:sg-out .5s ease-in both}
+.sg-alert-media{display:flex;justify-content:center;margin-bottom:.4em}
+.sg-alert-media img,.sg-alert-media video{display:block;max-width:100%;max-height:45vh;object-fit:contain;border-radius:.4em;background:transparent}
.sg-alert-head{font-weight:800;font-size:1.2em}
.sg-alert-head b{color:var(--sg-accent2)}
.sg-alert-msg{margin-top:.3em;font-size:.85em;overflow-wrap:anywhere;max-height:5.2em;overflow:hidden}
diff --git a/assets/overlay/overlay.js b/assets/overlay/overlay.js
index bd87960..6a3f9a9 100644
--- a/assets/overlay/overlay.js
+++ b/assets/overlay/overlay.js
@@ -113,16 +113,87 @@
firstAlertPoll = false;
next();
}
+ // Alert media (optional per alert): {visual:{type,url}|null, sound:{url}|null, volume, duration_ms, message}.
+ // Everything is built with createElement + property assignment; nothing from the server is parsed as HTML.
+ var MEDIA_TIMEOUT = 8000, DEFAULT_HOLD = 6500, VIDEO_CAP = 30000;
+ function okUrl(u) { return typeof u === 'string' && /^(https?:\/\/|\/)/i.test(u); }
+ function cleanMedia(m) {
+ if (!m || typeof m !== 'object') return null;
+ var v = m.visual && typeof m.visual === 'object' && okUrl(m.visual.url) && (m.visual.type === 'image' || m.visual.type === 'video') ? m.visual : null;
+ var s = m.sound && typeof m.sound === 'object' && okUrl(m.sound.url) ? m.sound : null;
+ var msg = typeof m.message === 'string' && m.message ? m.message : null;
+ if (!v && !s && !msg) return null;
+ var vol = Number(m.volume); if (!isFinite(vol)) vol = 80;
+ var dur = Number(m.duration_ms); if (!isFinite(dur) || dur <= 0) dur = DEFAULT_HOLD;
+ return { visual: v, sound: s, volume: Math.max(0, Math.min(100, vol)) / 100, duration: Math.max(1000, Math.min(60000, dur)), message: msg };
+ }
+ // Loads visual + sound before the card appears (no flash of an empty frame). Anything that fails or takes
+ // longer than MEDIA_TIMEOUT is dropped, so the alert falls back to text and the queue never stalls.
+ function preload(m, cb) {
+ var out = { visual: null, sound: null }, pending = 0, fired = false, timer = 0;
+ function finish() { if (fired) return; fired = true; clearTimeout(timer); cb(out); }
+ function part() { pending++; var once = false; return function (ok, set) { if (once) return; once = true; if (ok && set) set(); if (--pending <= 0) finish(); }; }
+ try {
+ if (m.visual) {
+ var vd = part();
+ if (m.visual.type === 'image') {
+ var img = new Image();
+ img.onload = function () { vd(true, function () { out.visual = img; }); };
+ img.onerror = function () { vd(false); };
+ img.src = m.visual.url;
+ } else {
+ var vid = document.createElement('video');
+ vid.preload = 'auto'; vid.playsInline = true; vid.muted = true;
+ vid.setAttribute('playsinline', ''); vid.setAttribute('muted', '');
+ vid.onloadeddata = function () { vd(true, function () { out.visual = vid; }); };
+ vid.onerror = function () { vd(false); };
+ vid.src = m.visual.url;
+ try { vid.load(); } catch (e) { vd(false); }
+ }
+ }
+ if (m.sound) {
+ var sd = part();
+ var au = new Audio();
+ au.preload = 'auto';
+ au.oncanplaythrough = function () { sd(true, function () { out.sound = au; }); };
+ au.onerror = function () { sd(false); };
+ au.src = m.sound.url;
+ try { au.load(); } catch (e2) { sd(false); }
+ }
+ } catch (e3) { /* fall through to the timeout/finish below */ }
+ if (!pending) { finish(); return; }
+ timer = setTimeout(finish, MEDIA_TIMEOUT);
+ }
function next() {
if (showing || !queue.length) return;
showing = true;
var a = queue.shift();
+ var m = null;
+ try { m = cleanMedia(a.media); } catch (e) { m = null; }
+ if (!m) { present(a, null, null); return; }
+ var called = false;
+ function go(assets) { if (called) return; called = true; try { present(a, m, assets); } catch (err) { forceDone(); } }
+ try { preload(m, go); } catch (e2) { go({ visual: null, sound: null }); }
+ }
+ function forceDone() { root.textContent = ''; showing = false; setTimeout(next, 0); }
+ function present(a, m, assets) {
root.textContent = '';
var card = el('div', 'sg-alert');
var head = el('div', 'sg-alert-head');
- head.appendChild(el('b', null, a.name));
- head.appendChild(document.createTextNode(' donated '));
- head.appendChild(el('b', null, a.amount_display));
+ var vis = assets && assets.visual, snd = assets && assets.sound;
+ if (vis) {
+ var box = el('div', 'sg-alert-media');
+ box.appendChild(vis);
+ card.appendChild(box);
+ card.classList.add('sg-has-media');
+ }
+ if (m && m.message) {
+ head.textContent = m.message;
+ } else {
+ head.appendChild(el('b', null, a.name));
+ head.appendChild(document.createTextNode(' donated '));
+ head.appendChild(el('b', null, a.amount_display));
+ }
card.appendChild(head);
var bonuses = Array.isArray(a.bonuses) ? a.bonuses : [];
if (bonuses.length) {
@@ -139,10 +210,51 @@
}
if (a.message) card.appendChild(el('div', 'sg-alert-msg', a.message));
root.appendChild(card);
- setTimeout(function () {
+
+ var finished = false, holdTimer = 0, capTimer = 0;
+ function stopMedia() {
+ try { if (snd) snd.pause(); } catch (e) { /* ignore */ }
+ try { if (vis && vis.tagName === 'VIDEO') { vis.pause(); vis.removeAttribute('src'); vis.load(); } } catch (e2) { /* ignore */ }
+ }
+ function exit() {
+ if (finished) return;
+ finished = true;
+ clearTimeout(holdTimer); clearTimeout(capTimer);
+ stopMedia();
card.classList.add('sg-out');
setTimeout(function () { root.textContent = ''; showing = false; next(); }, 500);
- }, 6500);
+ }
+ var hold = m ? m.duration : DEFAULT_HOLD, isVideo = false;
+ if (snd) {
+ try {
+ snd.volume = m.volume; snd.currentTime = 0;
+ var sp = snd.play();
+ if (sp && typeof sp.catch === 'function') sp.catch(function () { /* autoplay blocked: silent alert */ });
+ } catch (e3) { /* ignore */ }
+ }
+ if (vis && vis.tagName === 'VIDEO') {
+ isVideo = true;
+ try {
+ vis.loop = false;
+ vis.muted = !!snd || m.volume === 0; // a separate sound wins; otherwise the clip's own audio at the set volume
+ vis.volume = m.volume;
+ vis.onended = exit;
+ vis.onerror = exit;
+ var vp = vis.play();
+ if (vp && typeof vp.catch === 'function') {
+ vp.catch(function () {
+ // Autoplay with sound refused: retry muted so the picture still plays; give up (text only) if that fails too.
+ try {
+ vis.muted = true;
+ var again = vis.play();
+ if (again && typeof again.catch === 'function') again.catch(function () { if (vis.parentNode) vis.parentNode.removeChild(vis); clearTimeout(capTimer); holdTimer = setTimeout(exit, DEFAULT_HOLD); });
+ } catch (e4) { exit(); }
+ });
+ }
+ } catch (e5) { isVideo = false; }
+ }
+ if (isVideo) capTimer = setTimeout(exit, VIDEO_CAP); // videos play to the end, never longer than 30 s
+ else holdTimer = setTimeout(exit, hold);
}
// ---- actions (reward menu) ----
diff --git a/includes/Admin/Admin.php b/includes/Admin/Admin.php
index c70584f..2e61bc6 100644
--- a/includes/Admin/Admin.php
+++ b/includes/Admin/Admin.php
@@ -28,6 +28,9 @@ final class Admin {
'sg_action_save' => array( ActionsPage::class, 'handleSave' ),
'sg_action_toggle' => array( ActionsPage::class, 'handleToggle' ),
'sg_action_delete' => array( ActionsPage::class, 'handleDelete' ),
+ 'sg_alert_save' => array( AlertsPage::class, 'handleSave' ),
+ 'sg_alert_toggle' => array( AlertsPage::class, 'handleToggle' ),
+ 'sg_alert_delete' => array( AlertsPage::class, 'handleDelete' ),
'sg_event_done' => array( ActionsPage::class, 'handleDone' ),
'sg_event_done_all' => array( ActionsPage::class, 'handleDoneAll' ),
'sg_export_csv' => array( DonationsPage::class, 'handleExport' ),
@@ -65,6 +68,7 @@ final class Admin {
$queued = ActionsPage::queuedCount();
$qbadge = $queued > 0 ? ' ' . (int) $queued . '' : '';
add_submenu_page( self::HOME, 'Rewards', 'Rewards' . $qbadge, self::CAP, ActionsPage::PAGE, array( ActionsPage::class, 'render' ) );
+ add_submenu_page( self::HOME, 'Alerts', 'Alerts', self::CAP, AlertsPage::PAGE, array( AlertsPage::class, 'render' ) );
add_submenu_page( self::HOME, 'Overlays', 'Overlays', self::CAP, 'streamgoals-overlays', array( OverlaysPage::class, 'render' ) );
add_submenu_page( self::HOME, 'Settings', 'Settings', self::CAP, 'streamgoals-settings', array( SettingsPage::class, 'render' ) );
}
@@ -101,6 +105,11 @@ final class Admin {
if ( ActionsPage::PAGE === $page ) {
wp_enqueue_script( 'streamgoals-actions', STREAMGOALS_URL . 'assets/admin/actions.js', array( 'streamgoals-admin' ), STREAMGOALS_VERSION, true );
}
+ if ( AlertsPage::PAGE === $page ) {
+ wp_enqueue_media();
+ wp_enqueue_style( 'streamgoals-alerts', STREAMGOALS_URL . 'assets/admin/alerts.css', array( 'streamgoals-admin' ), STREAMGOALS_VERSION );
+ wp_enqueue_script( 'streamgoals-alerts', STREAMGOALS_URL . 'assets/admin/alerts.js', array( 'streamgoals-admin', 'jquery' ), STREAMGOALS_VERSION, true );
+ }
if ( 'streamgoals-overlays' === $page ) {
wp_enqueue_script( 'streamgoals-overlays', STREAMGOALS_URL . 'assets/admin/overlays.js', array( 'streamgoals-admin' ), STREAMGOALS_VERSION, true );
}
diff --git a/includes/Admin/AlertsPage.php b/includes/Admin/AlertsPage.php
new file mode 100644
index 0000000..e425f5c
--- /dev/null
+++ b/includes/Admin/AlertsPage.php
@@ -0,0 +1,238 @@
+ goal id => title */
+ private static function goalTitles(): array {
+ $out = array();
+ foreach ( Store::goals()->all() as $g ) {
+ $out[ (int) $g['id'] ] = (string) $g['title'];
+ }
+ return $out;
+ }
+
+ /** Attachment lookup for validation: mime + size, null when missing. */
+ public static function attachmentInfo( int $id ): ?array {
+ if ( $id <= 0 || 'attachment' !== get_post_type( $id ) ) {
+ return null;
+ }
+ $path = get_attached_file( $id );
+ return array(
+ 'mime' => (string) get_post_mime_type( $id ),
+ 'size' => ( is_string( $path ) && is_file( $path ) ) ? (int) filesize( $path ) : 0,
+ );
+ }
+
+ /* ---------------------------------------------------------------- render */
+
+ public static function render(): void {
+ Admin::open( 'Alerts' );
+ $edit = Admin::get_int( 'edit' );
+ if ( 'new' === Admin::get_str( 'view' ) || $edit ) {
+ self::renderForm( $edit );
+ } else {
+ self::renderHelp();
+ self::renderList();
+ }
+ Admin::close();
+ }
+
+ private static function renderHelp(): void {
+ echo '
Make your alerts come alive
';
+ echo '
An alert is the pop-up on your stream when someone donates. Here you can give it a picture, a GIF or a video, and a sound. Pick the donation size (or a reward) that should trigger it.
';
+ echo '
';
+ echo '
By amount: "Any donation of at least $X". If several match, the one with the highest $X wins.
';
+ echo '
By reward: plays when a donor triggers one of your rewards. A reward alert beats an amount alert.
';
+ echo '
Nothing set up? Alerts look and work exactly as before.
';
+ echo '
In OBS media plays automatically. In a normal browser tab you must click the page once before sound is allowed.
';
+ echo '
Pictures and GIFs stay for the time you choose. Videos play to the end, for at most 30 seconds.
';
+ echo '
Keep files small (under 25 MB). Big videos make OBS slow to load and can make your stream stutter.
Only you see this, for example "Big donation fireworks".
';
+ echo '
';
+ echo '
Plays when
';
+ echo '';
+ echo '
At least ' . esc_html( Format::money( self::minMinor(), $cur ) ) . ' (your minimum donation). If several amount alerts match, the one with the highest amount wins.
';
+ echo '
A reward alert beats an amount alert. Only rewards that are turned on can be picked.
';
+ self::mediaField( 'visual_id', 'Picture, GIF or video', 'visual', (int) $val( 'visual_id', 0 ), 'PNG, JPEG, GIF, WebP, MP4 or WebM. Optional. Under 25 MB works best; big videos can slow OBS down.' );
+ self::mediaField( 'sound_id', 'Sound', 'sound', (int) $val( 'sound_id', 0 ), 'MP3, OGG or WAV. Optional. If you also pick a video, the video is muted and this sound plays instead.' );
+ echo '
%
';
+ echo '
seconds
1 to 60. Videos play to the end instead, for at most 30 seconds.
';
+ echo '
Optional. Use {name}, {amount} and {reward}, for example "{name} just sent {amount}!". Leave empty for the normal text ("Name donated $5.00").
';
+ echo '
Lower numbers win when two alerts are otherwise equal. Leave empty to put it last.
';
+ echo '
';
+
+ echo '
Preview
';
+ echo '
This is how the alert will look on stream. Press the button to play it (browsers only allow sound after you click).