mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
screencast: properly revoke url objects.
This commit is contained in:
parent
b881a52fbb
commit
27dfdaad38
@ -13,7 +13,7 @@
|
|||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
@Ref('image') readonly _image!: HTMLImageElement
|
@Ref('image') readonly _image!: HTMLImageElement
|
||||||
active = false
|
private active = false
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly enabled!: boolean
|
private readonly enabled!: boolean
|
||||||
@ -25,17 +25,19 @@
|
|||||||
while (this.active) {
|
while (this.active) {
|
||||||
const lastLoad = Date.now()
|
const lastLoad = Date.now()
|
||||||
|
|
||||||
if (this._image.src) {
|
|
||||||
URL.revokeObjectURL(this._image.src)
|
|
||||||
}
|
|
||||||
|
|
||||||
const res = await this.api.screenCastImage({ responseType: 'blob' })
|
const res = await this.api.screenCastImage({ responseType: 'blob' })
|
||||||
this._image.src = URL.createObjectURL(res.data)
|
const image = URL.createObjectURL(res.data)
|
||||||
|
|
||||||
|
if (this._image) {
|
||||||
|
this._image.src = image
|
||||||
|
}
|
||||||
|
|
||||||
const delay = lastLoad - Date.now() + REFRESH_RATE
|
const delay = lastLoad - Date.now() + REFRESH_RATE
|
||||||
if (delay > 0) {
|
if (delay > 0) {
|
||||||
await new Promise((res) => setTimeout(res, delay))
|
await new Promise((res) => setTimeout(res, delay))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
URL.revokeObjectURL(image)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,17 +52,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
this.active = true
|
if (!this.active) {
|
||||||
|
this.active = true
|
||||||
setTimeout(this.loop, 0)
|
setTimeout(this.loop, 0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
this.active = false
|
this.active = false
|
||||||
|
|
||||||
if (this._image && this._image.src) {
|
|
||||||
URL.revokeObjectURL(this._image.src)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch('enabled')
|
@Watch('enabled')
|
||||||
|
Loading…
Reference in New Issue
Block a user