-
-
+
@@ -9,29 +8,18 @@
花费 {{ (item.price * item.discount) / 100 }} 点 立即购买
-
-
-
-
- 结束播放
-
-
-
-
-
-
-
- 看视频
-
-
- 听音频
-
-
-
+
+
+ 看视频
+
+
+ 听音频
+
+
@@ -49,32 +37,18 @@ const item = ref({
title: "加载中...",
});
-const currentTime = ref(0);
-const duration = ref(0);
-const playing = ref(false);
-
onBeforeUnmount(() => {
const player = document.getElementById("video");
- if (player && playing.value) {
- stop();
+ if (player) {
+ player.pause();
}
});
onMounted(() => {
loadMedia(route.params.hash);
const player = document.getElementById("video");
- player.addEventListener("timeupdate", updateTime);
- player.addEventListener("loadedmetadata", () => {
- duration.value = player.duration;
- });
player.addEventListener("ended", function () {
console.log("Video ended");
- playing.value = false;
- });
- player.addEventListener("pause", () => {
- playing.value = false;
- player.currentTime = 0;
- currentTime.value = 0;
});
});
@@ -154,8 +128,6 @@ const loadMedia = (hash) => {
};
const play = (hash, type) => {
- playing.value = true;
-
const player = document.getElementById("video");
const source = `/v1/medias/${hash}/${type}`;
if (Hls.isSupported()) {
@@ -176,27 +148,6 @@ const play = (hash, type) => {
});
}
};
-
-const updateTime = () => {
- const player = document.getElementById("video");
- currentTime.value = player?.currentTime;
-};
-
-const stop = () => {
- const player = document.getElementById("video");
- if (!player) {
- return;
- }
- player.pause();
- player.currentTime = 0;
- currentTime.value = 0;
-};
-
-const formatTime = (time) => {
- const minutes = Math.floor(time / 60);
- const seconds = Math.floor(time % 60);
- return `${minutes}:${seconds < 10 ? "0" : ""}${seconds}`;
-};