mediaplayer: cache now-playing tags;

fixes copy-to-irc after navigating to another folder
This commit is contained in:
ed 2025-12-12 22:52:18 +00:00
parent 8e2fb05ab8
commit 1a9d4c04d5

View file

@ -1242,6 +1242,7 @@ var mpl = (function () {
"os_ctl": bcfg_get('au_os_ctl', have_mctl) && have_mctl, "os_ctl": bcfg_get('au_os_ctl', have_mctl) && have_mctl,
'traversals': 0, 'traversals': 0,
'm3ut': '#EXTM3U\n', 'm3ut': '#EXTM3U\n',
'np': [{'file': 'nothing'}, ['file']],
}; };
bcfg_bind(r, 'one', 'au_one', false, function (v) { bcfg_bind(r, 'one', 'au_one', false, function (v) {
if (mp.au) if (mp.au)
@ -1438,7 +1439,7 @@ var mpl = (function () {
if (!r.os_ctl || !mp.au) if (!r.os_ctl || !mp.au)
return; return;
var np = get_np()[0], var np = mpl.np[0],
fns = np.file.split(' - '), fns = np.file.split(' - '),
artist = (np.circle && np.circle != np.artist ? np.circle + ' // ' : '') + (np.artist || (fns.length > 1 ? fns[0] : '')), artist = (np.circle && np.circle != np.artist ? np.circle + ' // ' : '') + (np.artist || (fns.length > 1 ? fns[0] : '')),
title = np.title || fns.pop(), title = np.title || fns.pop(),
@ -1784,12 +1785,6 @@ function ft2dict(tr, skip) {
} }
function get_np() {
var tr = QS('#files tr.play');
return ft2dict(tr, { 'up_ip': 1 });
};
// toggle player widget // toggle player widget
var widget = (function () { var widget = (function () {
var r = {}, var r = {},
@ -1847,9 +1842,8 @@ var widget = (function () {
ck = irc ? '06' : '', ck = irc ? '06' : '',
cv = irc ? '07' : '', cv = irc ? '07' : '',
m = ck + 'np: ', m = ck + 'np: ',
npr = get_np(), npk = mpl.np[1],
npk = npr[1], np = mpl.np[0];
np = npr[0];
for (var a = 0; a < npk.length; a++) for (var a = 0; a < npk.length; a++)
m += (npk[a] == 'file' ? '' : npk[a]).replace(/^\./, '') + '(' + cv + np[npk[a]] + ck + ') // '; m += (npk[a] == 'file' ? '' : npk[a]).replace(/^\./, '') + '(' + cv + np[npk[a]] + ck + ') // ';
@ -3103,9 +3097,12 @@ function play(tid, is_ev, seek) {
for (var a = 0, aa = trs.length; a < aa; a++) for (var a = 0, aa = trs.length; a < aa; a++)
clmod(trs[a], 'play'); clmod(trs[a], 'play');
var oid = 'a' + tid; var oid = 'a' + tid,
clmod(ebi(oid), 'act', 1); t_a = ebi(oid),
clmod(ebi(oid).closest('tr'), 'play', 1); t_tr = t_a.closest('tr');
clmod(t_a, 'act', 1);
clmod(t_tr, 'play', 1);
clmod(ebi('wtoggle'), 'np', mpl.clip); clmod(ebi('wtoggle'), 'np', mpl.clip);
clmod(ebi('wtoggle'), 'm3u', mpl.m3uen); clmod(ebi('wtoggle'), 'm3u', mpl.m3uen);
if (thegrid) if (thegrid)
@ -3127,12 +3124,12 @@ function play(tid, is_ev, seek) {
} }
if (!seek && !ebi('unsearch')) { if (!seek && !ebi('unsearch')) {
var o = ebi(oid); t_a.setAttribute('id', 'thx_js');
o.setAttribute('id', 'thx_js');
if (mpl.aplay) if (mpl.aplay)
sethash(oid + getsort()); sethash(oid + getsort());
o.setAttribute('id', oid); t_a.setAttribute('id', oid);
} }
mpl.np = ft2dict(t_tr, { 'up_ip': 1 });
pbar.unwave(); pbar.unwave();
if (mpl.waves) if (mpl.waves)
@ -3147,7 +3144,7 @@ function play(tid, is_ev, seek) {
catch (ex) { catch (ex) {
toast.err(0, esc(L.mm_playerr + basenames(ex))); toast.err(0, esc(L.mm_playerr + basenames(ex)));
} }
clmod(ebi(oid), 'act'); clmod(t_a, 'act');
mpl.t_eplay = setTimeout(next_song, 5000); mpl.t_eplay = setTimeout(next_song, 5000);
} }