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