mirror of
https://github.com/TeamPiped/Piped.git
synced 2025-04-26 16:46:32 +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");
|
||||
import muxjs from "mux.js";
|
||||
window.muxjs = muxjs;
|
||||
const hotkeys = import("hotkeys-js");
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@ -62,14 +63,13 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
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() {
|
||||
import("hotkeys-js")
|
||||
.then(mod => mod.default)
|
||||
.then(hotkeys => {
|
||||
this.hotkeys = hotkeys;
|
||||
this.hotkeysPromise.then(() => {
|
||||
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+.",
|
||||
function (e, handler) {
|
||||
const videoEl = self.$refs.videoEl;
|
||||
@ -168,10 +168,10 @@ export default {
|
||||
});
|
||||
},
|
||||
deactivated() {
|
||||
this.destroy();
|
||||
this.destroy(true);
|
||||
},
|
||||
unmounted() {
|
||||
this.destroy();
|
||||
this.destroy(true);
|
||||
},
|
||||
methods: {
|
||||
async loadVideo() {
|
||||
@ -514,7 +514,7 @@ export default {
|
||||
this.$refs.videoEl.currentTime = time;
|
||||
}
|
||||
},
|
||||
destroy() {
|
||||
destroy(hotkeys) {
|
||||
if (this.$ui) {
|
||||
this.$ui.destroy();
|
||||
this.$ui = undefined;
|
||||
@ -524,7 +524,7 @@ export default {
|
||||
this.$player.destroy();
|
||||
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());
|
||||
},
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user