Autoplay Policy Changes mitigation attempt #1
This commit is contained in:
parent
4a44e412e7
commit
6f06d70ff6
@ -41,6 +41,25 @@
|
||||
}
|
||||
window.isMobile = window.mobilecheck()
|
||||
|
||||
// Context bullshit
|
||||
let playerContext = []
|
||||
|
||||
window.resumeContexts = function () {
|
||||
for (let i in playerContext) {
|
||||
let ctx = playerContext[i]
|
||||
if (ctx && ctx.resume) {
|
||||
ctx.resume().catch(function (e) {
|
||||
console.error(e)
|
||||
alert('Failed to play:', e.message)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.attachAudioContext = function (ctx) {
|
||||
playerContext.push(ctx)
|
||||
}
|
||||
|
||||
// Seconds into HH:MM:SS
|
||||
function toHHMMSS (numbr) {
|
||||
let secNum = parseInt(numbr, 10) // don't forget the second param
|
||||
@ -331,6 +350,8 @@
|
||||
audio.src = '/api/serve/by-id/' + id
|
||||
audio.play()
|
||||
|
||||
window.resumeAudioContexts()
|
||||
|
||||
updateQT(q)
|
||||
|
||||
nowPlaying = id
|
||||
|
@ -12,6 +12,8 @@
|
||||
var volBar = document.querySelector('#player-volbar .seek-inner')
|
||||
var volElem = document.querySelector('.volume')
|
||||
|
||||
var playerContext = []
|
||||
|
||||
// Seconds into HH:MM:SS
|
||||
function toHHMMSS (numbr) {
|
||||
let secNum = parseInt(numbr, 10) // don't forget the second param
|
||||
@ -170,6 +172,7 @@
|
||||
} else {
|
||||
audio.pause()
|
||||
}
|
||||
window.resumeAudioContexts()
|
||||
}, false)
|
||||
|
||||
mute.addEventListener('click', function (e) {
|
||||
|
@ -63,6 +63,7 @@
|
||||
renderFrame()
|
||||
|
||||
window.addEventListener('resize', convenientSizer)
|
||||
window.attachAudioContext(context)
|
||||
|
||||
convenientSizer()
|
||||
})()
|
||||
|
Loading…
Reference in New Issue
Block a user