mirror of
https://github.com/9001/copyparty.git
synced 2025-08-18 01:22:13 -06:00
more safari-on-touchbar-macbook workarounds:
* safari invokes pause on the mediasession whenever any Audio loads a new src (preload) * ...and on some(?) seeks
This commit is contained in:
parent
f2a7925387
commit
f5fe3678ee
|
@ -1496,7 +1496,7 @@ var mpl = (function () {
|
||||||
r.announce = announce;
|
r.announce = announce;
|
||||||
|
|
||||||
r.stop = function () {
|
r.stop = function () {
|
||||||
if (!r.os_ctl || !navigator.mediaSession.metadata)
|
if (!r.os_ctl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
navigator.mediaSession.metadata = null;
|
navigator.mediaSession.metadata = null;
|
||||||
|
@ -1505,6 +1505,8 @@ var mpl = (function () {
|
||||||
var hs = 'play pause seekbackward seekforward previoustrack nexttrack'.split(/ /g);
|
var hs = 'play pause seekbackward seekforward previoustrack nexttrack'.split(/ /g);
|
||||||
for (var a = 0; a < hs.length; a++)
|
for (var a = 0; a < hs.length; a++)
|
||||||
navigator.mediaSession.setActionHandler(hs[a], null);
|
navigator.mediaSession.setActionHandler(hs[a], null);
|
||||||
|
|
||||||
|
navigator.mediaSession.setPositionState();
|
||||||
};
|
};
|
||||||
|
|
||||||
r.unbuffer = function (url) {
|
r.unbuffer = function (url) {
|
||||||
|
@ -1544,6 +1546,7 @@ function MPlayer() {
|
||||||
r.au2 = null;
|
r.au2 = null;
|
||||||
r.tracks = {};
|
r.tracks = {};
|
||||||
r.order = [];
|
r.order = [];
|
||||||
|
r.cd_pause = 0;
|
||||||
|
|
||||||
var re_audio = have_acode && mpl.ac_oth ? re_au_all : re_au_native,
|
var re_audio = have_acode && mpl.ac_oth ? re_au_all : re_au_native,
|
||||||
trs = QSA('#files tbody tr');
|
trs = QSA('#files tbody tr');
|
||||||
|
@ -1600,6 +1603,7 @@ function MPlayer() {
|
||||||
r.ftid = -1;
|
r.ftid = -1;
|
||||||
r.ftimer = null;
|
r.ftimer = null;
|
||||||
r.fade_in = function () {
|
r.fade_in = function () {
|
||||||
|
r.nopause();
|
||||||
r.fvol = 0;
|
r.fvol = 0;
|
||||||
r.fdir = 0.025 * r.vol * (CHROME ? 1.5 : 1);
|
r.fdir = 0.025 * r.vol * (CHROME ? 1.5 : 1);
|
||||||
if (r.au) {
|
if (r.au) {
|
||||||
|
@ -1632,9 +1636,9 @@ function MPlayer() {
|
||||||
r.au.pause();
|
r.au.pause();
|
||||||
mpl.pp();
|
mpl.pp();
|
||||||
|
|
||||||
var t = mp.au.currentTime - 0.8;
|
var t = r.au.currentTime - 0.8;
|
||||||
if (isNum(t))
|
if (isNum(t))
|
||||||
mp.au.currentTime = Math.max(t, 0);
|
r.au.currentTime = Math.max(t, 0);
|
||||||
}
|
}
|
||||||
else if (r.fvol > r.vol)
|
else if (r.fvol > r.vol)
|
||||||
r.fvol = r.vol;
|
r.fvol = r.vol;
|
||||||
|
@ -1680,8 +1684,14 @@ function MPlayer() {
|
||||||
drop();
|
drop();
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.au2.preload = "auto";
|
r.nopause();
|
||||||
mp.au2.src = mp.au2.rsrc = url;
|
r.au2.onloadeddata = r.au2.onloadedmetadata = r.nopause;
|
||||||
|
r.au2.preload = "auto";
|
||||||
|
r.au2.src = r.au2.rsrc = url;
|
||||||
|
};
|
||||||
|
|
||||||
|
r.nopause = function () {
|
||||||
|
r.cd_pause = Date.now();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1820,7 +1830,7 @@ function glossy_grad(can, h, s, l) {
|
||||||
var pbar = (function () {
|
var pbar = (function () {
|
||||||
var r = {},
|
var r = {},
|
||||||
bau = null,
|
bau = null,
|
||||||
html_cdown = 0,
|
html_txt = 'a',
|
||||||
lastmove = 0,
|
lastmove = 0,
|
||||||
mousepos = 0,
|
mousepos = 0,
|
||||||
gradh = -1,
|
gradh = -1,
|
||||||
|
@ -1991,10 +2001,14 @@ var pbar = (function () {
|
||||||
pctx.fillText(t1, xt1, yt);
|
pctx.fillText(t1, xt1, yt);
|
||||||
pctx.fillText(t2, xt2, yt);
|
pctx.fillText(t2, xt2, yt);
|
||||||
|
|
||||||
if (html_cdown < Date.now() - 99) {
|
if (w && html_txt != t2) {
|
||||||
html_cdown = Date.now();
|
ebi('np_pos').textContent = html_txt = t2;
|
||||||
if (ebi('np_pos').textContent != t2)
|
if (mpl.os_ctl)
|
||||||
ebi('np_pos').textContent = t2;
|
navigator.mediaSession.setPositionState({
|
||||||
|
'duration': adur,
|
||||||
|
'position': apos,
|
||||||
|
'playbackRate': 1
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2125,6 +2139,7 @@ function seek_au_sec(seek) {
|
||||||
if (!isNum(seek))
|
if (!isNum(seek))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
mp.nopause();
|
||||||
mp.au.currentTime = seek;
|
mp.au.currentTime = seek;
|
||||||
|
|
||||||
if (mp.au.paused)
|
if (mp.au.paused)
|
||||||
|
@ -2198,7 +2213,7 @@ function playpause(e) {
|
||||||
|
|
||||||
|
|
||||||
function mplay(e) {
|
function mplay(e) {
|
||||||
if (mp && mp.au && !mp.au.paused)
|
if (mp.au && !mp.au.paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
playpause(e);
|
playpause(e);
|
||||||
|
@ -2206,7 +2221,10 @@ function mplay(e) {
|
||||||
|
|
||||||
|
|
||||||
function mpause(e) {
|
function mpause(e) {
|
||||||
if (mp && mp.au && mp.au.paused)
|
if (mp.cd_pause > Date.now() - 100)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (mp.au && mp.au.paused)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
playpause(e);
|
playpause(e);
|
||||||
|
@ -2760,6 +2778,7 @@ function play(tid, is_ev, seek) {
|
||||||
scroll2playing();
|
scroll2playing();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
mp.nopause();
|
||||||
mp.au.play();
|
mp.au.play();
|
||||||
if (mp.au.paused)
|
if (mp.au.paused)
|
||||||
autoplay_blocked(seek);
|
autoplay_blocked(seek);
|
||||||
|
|
Loading…
Reference in a new issue