Skip to content

Commit

Permalink
Opt: add no muted play error notify
Browse files Browse the repository at this point in the history
  • Loading branch information
zijiren233 committed Oct 7, 2023
1 parent 4fa7859 commit 8db447a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/components/Player.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ const playM3u8 = (player: HTMLMediaElement, url: string, art: any) => {
const playerOption = computed<Option>(() => {
return {
muted: true,
container: artplayer.value!,
volume: 0, // 音量
autoSize: false, // 隐藏黑边
Expand Down
23 changes: 19 additions & 4 deletions src/plugins/sync.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { ref, watch } from "vue";
import type { WatchStopHandle } from "vue";
import { roomStore } from "@/stores/room";
import { devLog, getFileExtension } from "@/utils/utils";
import { devLog } from "@/utils/utils";
import Notify from "@/utils/notify";
import { useDebounceFn } from "@vueuse/core";
import { WsMessageType } from "@/types/Room";
import type { BaseMovieInfo, MovieInfo, EditMovieInfo, MovieStatus } from "@/types/Movie";
import { ElNotification, ElMessage } from "element-plus";
const room = roomStore();

interface callback {
Expand Down Expand Up @@ -63,7 +64,14 @@ export const sync = (cbk: callback) => {
art.once("play", () => {
art.on("play", publishPlayOrPause);
});
art.play();
art.play().catch(() => {
art.muted = true;
art.play();
ElNotification({
title: "温馨提示",
message: "由于浏览器限制,播放器已静音,请手动开启声音"
});
});
} else {
art.off("pause", publishPlayOrPause);
art.once("pause", () => {
Expand Down Expand Up @@ -154,7 +162,14 @@ export const sync = (cbk: callback) => {
});
} else {
art.once("ready", () => {
art.play();
art.play().catch(() => {
art.muted = true;
art.play();
ElNotification({
title: "温馨提示",
message: "由于浏览器限制,播放器已静音,请手动开启声音"
});
});
cbk["ws-send"]("PLAYER:视频已就绪");
});
}
Expand Down

0 comments on commit 8db447a

Please sign in to comment.