mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
screencast singleton.
This commit is contained in:
parent
27dfdaad38
commit
27422294bc
@ -13,7 +13,8 @@
|
|||||||
})
|
})
|
||||||
export default class extends Vue {
|
export default class extends Vue {
|
||||||
@Ref('image') readonly _image!: HTMLImageElement
|
@Ref('image') readonly _image!: HTMLImageElement
|
||||||
private active = false
|
private running = false
|
||||||
|
private continue = false
|
||||||
|
|
||||||
@Prop()
|
@Prop()
|
||||||
private readonly enabled!: boolean
|
private readonly enabled!: boolean
|
||||||
@ -22,7 +23,10 @@
|
|||||||
private readonly api!: RoomApi
|
private readonly api!: RoomApi
|
||||||
|
|
||||||
async loop() {
|
async loop() {
|
||||||
while (this.active) {
|
if (this.running) return
|
||||||
|
this.running = true
|
||||||
|
|
||||||
|
while (this.continue) {
|
||||||
const lastLoad = Date.now()
|
const lastLoad = Date.now()
|
||||||
|
|
||||||
const res = await this.api.screenCastImage({ responseType: 'blob' })
|
const res = await this.api.screenCastImage({ responseType: 'blob' })
|
||||||
@ -39,6 +43,8 @@
|
|||||||
|
|
||||||
URL.revokeObjectURL(image)
|
URL.revokeObjectURL(image)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.running = false
|
||||||
}
|
}
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -52,14 +58,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
if (!this.active) {
|
if (!this.running) {
|
||||||
this.active = true
|
this.continue = true
|
||||||
setTimeout(this.loop, 0)
|
setTimeout(this.loop, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
this.active = false
|
this.continue = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@Watch('enabled')
|
@Watch('enabled')
|
||||||
|
Loading…
Reference in New Issue
Block a user