mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-11-10 10:18:23 +00:00
Load hotkey-js only once and fix destroy.
This commit is contained in:
parent
de8fb4fab5
commit
1d6a6daa06
@ -9,6 +9,7 @@ import("shaka-player/dist/controls.css");
|
|||||||
const shaka = import("shaka-player/dist/shaka-player.ui.js");
|
const shaka = import("shaka-player/dist/shaka-player.ui.js");
|
||||||
import muxjs from "mux.js";
|
import muxjs from "mux.js";
|
||||||
window.muxjs = muxjs;
|
window.muxjs = muxjs;
|
||||||
|
const hotkeys = import("hotkeys-js");
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@ -62,14 +63,13 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (!this.shaka) this.shakaPromise = shaka.then(shaka => shaka.default).then(shaka => (this.shaka = shaka));
|
if (!this.shaka) this.shakaPromise = shaka.then(shaka => shaka.default).then(shaka => (this.shaka = shaka));
|
||||||
|
if (!this.$hotkeys)
|
||||||
|
this.hotkeysPromise = hotkeys.then(mod => mod.default).then(hotkeys => (this.$hotkeys = hotkeys));
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
import("hotkeys-js")
|
this.hotkeysPromise.then(() => {
|
||||||
.then(mod => mod.default)
|
|
||||||
.then(hotkeys => {
|
|
||||||
this.hotkeys = hotkeys;
|
|
||||||
var self = this;
|
var self = this;
|
||||||
hotkeys(
|
this.$hotkeys(
|
||||||
"f,m,j,k,l,c,space,up,down,left,right,0,1,2,3,4,5,6,7,8,9,shift+,,shift+.",
|
"f,m,j,k,l,c,space,up,down,left,right,0,1,2,3,4,5,6,7,8,9,shift+,,shift+.",
|
||||||
function (e, handler) {
|
function (e, handler) {
|
||||||
const videoEl = self.$refs.videoEl;
|
const videoEl = self.$refs.videoEl;
|
||||||
@ -168,10 +168,10 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
deactivated() {
|
deactivated() {
|
||||||
this.destroy();
|
this.destroy(true);
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
this.destroy();
|
this.destroy(true);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async loadVideo() {
|
async loadVideo() {
|
||||||
@ -514,7 +514,7 @@ export default {
|
|||||||
this.$refs.videoEl.currentTime = time;
|
this.$refs.videoEl.currentTime = time;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
destroy() {
|
destroy(hotkeys) {
|
||||||
if (this.$ui) {
|
if (this.$ui) {
|
||||||
this.$ui.destroy();
|
this.$ui.destroy();
|
||||||
this.$ui = undefined;
|
this.$ui = undefined;
|
||||||
@ -524,7 +524,7 @@ export default {
|
|||||||
this.$player.destroy();
|
this.$player.destroy();
|
||||||
this.$player = undefined;
|
this.$player = undefined;
|
||||||
}
|
}
|
||||||
if (this.hotkeys) this.hotkeys.unbind();
|
if (this.$hotkeys && hotkeys) this.$hotkeys.unbind();
|
||||||
if (this.$refs.container) this.$refs.container.querySelectorAll("div").forEach(node => node.remove());
|
if (this.$refs.container) this.$refs.container.querySelectorAll("div").forEach(node => node.remove());
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user