Skip to content

Commit 921d852

Browse files
author
Taois
committed
feat: 播放器界面优化日志
1 parent 1733bbd commit 921d852

File tree

3 files changed

+24
-72
lines changed

3 files changed

+24
-72
lines changed

dashboard/src/components/players/ArtVideoPlayer.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,11 @@ const initArtPlayer = async (url) => {
568568
})
569569
570570
art.on('video:loadstart', () => {
571-
console.log('开始加载视频')
572571
// 重置片头片尾跳过状态
573572
resetSkipState()
574573
})
575574
576575
art.on('video:canplay', () => {
577-
console.log('视频可以播放')
578576
// 视频可以播放时,重置重连计数器
579577
resetRetryState()
580578
// 应用片头片尾设置
@@ -595,7 +593,6 @@ const initArtPlayer = async (url) => {
595593
})
596594
597595
art.on('video:playing', () => {
598-
console.log('视频开始播放')
599596
// 视频开始播放时,重置重连计数器
600597
resetRetryState()
601598
@@ -615,8 +612,6 @@ const initArtPlayer = async (url) => {
615612
616613
// 监听全屏状态变化
617614
art.on('fullscreen', (isFullscreen) => {
618-
console.log('全屏状态变化:', isFullscreen)
619-
620615
// 标记全屏状态开始变化
621616
onFullscreenChangeStart()
622617
@@ -751,7 +746,6 @@ const handleRetry = (url) => {
751746
const resetRetryState = () => {
752747
retryCount.value = 0
753748
isRetrying.value = false
754-
console.log('重连状态已重置')
755749
}
756750
757751
// 计算动态高度
@@ -829,13 +823,11 @@ const cancelAutoNext = () => {
829823
// 立即播放下一集
830824
const playNextEpisode = () => {
831825
if (!hasNextEpisode()) {
832-
console.log('已经是最后一集')
833826
Message.info('已经是最后一集了')
834827
return
835828
}
836829
837830
const nextEpisode = getNextEpisode()
838-
console.log('播放下一集:', nextEpisode.name)
839831
840832
// 清理倒计时
841833
cancelAutoNext()
@@ -850,7 +842,6 @@ const playNextEpisode = () => {
850842
// 切换自动下一集开关
851843
const toggleAutoNext = () => {
852844
autoNextEnabled.value = !autoNextEnabled.value
853-
console.log('自动下一集开关:', autoNextEnabled.value ? '开启' : '关闭')
854845
855846
if (!autoNextEnabled.value) {
856847
cancelAutoNext()

dashboard/src/components/players/VideoPlayer.vue

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,11 @@ const isDirectVideoLink = (url) => {
288288
const initVideoPlayer = (url) => {
289289
if (!videoPlayer.value || !url) return
290290
291-
console.log('初始化视频播放器:', url)
292-
293291
// 重置片头片尾跳过状态
294292
resetSkipState()
295293
296294
// 首先判断链接类型
297295
if (!isDirectVideoLink(url)) {
298-
console.log('检测到网页链接,在新窗口打开:', url)
299296
Message.info('检测到网页链接,正在新窗口打开...')
300297
window.open(url, '_blank')
301298
emit('close') // 关闭播放器
@@ -312,11 +309,8 @@ const initVideoPlayer = (url) => {
312309
313310
// 视频结束事件处理函数
314311
const handleVideoEnded = () => {
315-
console.log('视频播放结束')
316-
317312
// 防抖:如果正在处理自动连播,则忽略
318313
if (isProcessingAutoNext.value) {
319-
console.log('正在处理自动连播,忽略重复的ended事件')
320314
return
321315
}
322316
@@ -402,12 +396,10 @@ const initVideoPlayer = (url) => {
402396
}
403397
} else {
404398
// 处理其他格式的视频(mp4, webm, avi等)
405-
console.log('播放普通视频格式:', url)
406399
video.src = url
407400
408401
// 添加事件监听器
409402
const handleLoadedMetadata = () => {
410-
console.log('视频元数据加载完成,开始播放')
411403
video.play().catch(err => {
412404
console.warn('自动播放失败:', err)
413405
Message.warning('自动播放失败,请手动点击播放')
@@ -422,7 +414,6 @@ const initVideoPlayer = (url) => {
422414
423415
// 如果播放失败,再次检查是否为网页链接
424416
if (!isDirectVideoLink(url)) {
425-
console.log('播放失败,检测到可能是网页链接,在新窗口打开:', url)
426417
Message.info('视频播放失败,检测到网页链接,正在新窗口打开...')
427418
window.open(url, '_blank')
428419
emit('close') // 关闭播放器
@@ -433,13 +424,11 @@ const initVideoPlayer = (url) => {
433424
}
434425
435426
const handleLoadStart = () => {
436-
console.log('开始加载视频')
437427
// 重置片头片尾跳过状态
438428
resetSkipState()
439429
}
440430
441431
const handlePlaying = () => {
442-
console.log('视频开始播放')
443432
// 延迟一点应用跳过设置,确保视频已经开始播放
444433
setTimeout(() => {
445434
applySkipSettings()

dashboard/src/composables/useSkipSettings.js

Lines changed: 24 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -102,46 +102,29 @@ export function useSkipSettings(options = {}) {
102102
* 立即应用片头跳过逻辑(用于视频刚开始播放时)
103103
*/
104104
const applyIntroSkipImmediate = () => {
105-
console.log('applyIntroSkipImmediate 被调用')
106-
107-
if (!skipIntroEnabled.value) {
108-
console.log('片头跳过未启用')
109-
return
110-
}
111-
112-
if (skipIntroApplied.value) {
113-
console.log('片头跳过已应用,跳过')
114-
return
105+
if (!skipIntroEnabled.value || skipIntroApplied.value) {
106+
return false
115107
}
116108

117109
const currentTime = getCurrentTime()
118110
const now = Date.now()
119111

120112
// 检查用户是否正在拖动或刚刚拖动过(3秒内)
121113
if (userSeeking.value || (lastUserSeekTime.value > 0 && now - lastUserSeekTime.value < 3000)) {
122-
console.log('用户正在拖动进度条或刚刚拖动过,跳过自动片头跳过')
123-
return
124-
}
125-
126-
// 检查是否正在全屏切换或刚刚切换过(2秒内)
127-
if (isFullscreenChanging.value || (lastFullscreenChangeTime.value > 0 && now - lastFullscreenChangeTime.value < 2000)) {
128-
console.log('正在全屏切换或刚刚切换过,跳过自动片头跳过')
129-
return
114+
return false
130115
}
131116

132117
// 检查是否正在全屏切换或刚刚切换过(2秒内)
133118
if (isFullscreenChanging.value || (lastFullscreenChangeTime.value > 0 && now - lastFullscreenChangeTime.value < 2000)) {
134-
console.log('正在全屏切换或刚刚切换过,跳过自动片头跳过')
135-
return
119+
return false
136120
}
137121

138122
// 立即跳过模式:如果当前时间很小(小于等于1秒)且在片头跳过范围内,立即跳过
139123
if (currentTime <= 1 && currentTime <= skipIntroSeconds.value) {
140-
console.log(`立即跳过片头:从 ${currentTime} 秒跳转到 ${skipIntroSeconds.value}`)
124+
console.log(`立即跳过片头:从 ${currentTime.toFixed(1)}s 跳转到 ${skipIntroSeconds.value}s`)
141125
setCurrentTime(skipIntroSeconds.value)
142126
skipIntroApplied.value = true
143127
lastSkipTime.value = now
144-
console.log(`已立即跳过片头 ${skipIntroSeconds.value} 秒`)
145128
return true // 返回 true 表示已执行跳过
146129
}
147130

@@ -152,21 +135,7 @@ export function useSkipSettings(options = {}) {
152135
* 应用片头跳过逻辑
153136
*/
154137
const applyIntroSkip = () => {
155-
console.log('applyIntroSkip 被调用', {
156-
skipIntroEnabled: skipIntroEnabled.value,
157-
skipIntroApplied: skipIntroApplied.value,
158-
currentTime: getCurrentTime(),
159-
skipIntroSeconds: skipIntroSeconds.value,
160-
userSeeking: userSeeking.value
161-
})
162-
163-
if (!skipIntroEnabled.value) {
164-
console.log('片头跳过未启用')
165-
return
166-
}
167-
168-
if (skipIntroApplied.value) {
169-
console.log('片头跳过已应用,跳过')
138+
if (!skipIntroEnabled.value || skipIntroApplied.value) {
170139
return
171140
}
172141

@@ -175,32 +144,25 @@ export function useSkipSettings(options = {}) {
175144

176145
// 检查用户是否正在拖动或刚刚拖动过(3秒内)
177146
if (userSeeking.value || (lastUserSeekTime.value > 0 && now - lastUserSeekTime.value < 3000)) {
178-
console.log('用户正在拖动进度条或刚刚拖动过,跳过自动片头跳过')
179147
return
180148
}
181149

182150
// 检查是否正在全屏切换或刚刚切换过(2秒内)
183151
if (isFullscreenChanging.value || (lastFullscreenChangeTime.value > 0 && now - lastFullscreenChangeTime.value < 2000)) {
184-
console.log('正在全屏切换或刚刚切换过,跳过自动片头跳过')
185152
return
186153
}
187154

188155
// 防抖:如果距离上次跳过不足1秒,则忽略(但如果是新视频,lastSkipTime为0,允许跳过)
189-
// 减少防抖时间,提高响应速度
190156
if (lastSkipTime.value > 0 && now - lastSkipTime.value < 1000) {
191-
console.log('防抖限制,跳过')
192157
return
193158
}
194159

195160
// 如果当前时间在片头跳过范围内,则跳过
196161
if (currentTime <= skipIntroSeconds.value) {
197-
console.log(`准备跳过片头:从 ${currentTime} 秒跳转到 ${skipIntroSeconds.value}`)
162+
console.log(`已跳过片头:从 ${currentTime.toFixed(1)}s 跳转到 ${skipIntroSeconds.value}s`)
198163
setCurrentTime(skipIntroSeconds.value)
199164
skipIntroApplied.value = true
200165
lastSkipTime.value = now
201-
console.log(`已跳过片头 ${skipIntroSeconds.value} 秒`)
202-
} else {
203-
console.log(`当前时间 ${currentTime} 秒已超过片头跳过范围 ${skipIntroSeconds.value} 秒`)
204166
}
205167
}
206168

@@ -247,19 +209,29 @@ export function useSkipSettings(options = {}) {
247209
applyOutroSkip()
248210
}
249211

212+
// 防抖变量
213+
let timeUpdateDebounceTimer = null
214+
250215
/**
251216
* 处理时间更新事件
252217
*/
253218
const handleTimeUpdate = () => {
254-
// 应用片头跳过(仅在未应用时)
255-
if (skipIntroEnabled.value && !skipIntroApplied.value) {
256-
applyIntroSkip()
219+
// 防抖:减少频繁调用,每200ms最多执行一次
220+
if (timeUpdateDebounceTimer) {
221+
clearTimeout(timeUpdateDebounceTimer)
257222
}
223+
224+
timeUpdateDebounceTimer = setTimeout(() => {
225+
// 应用片头跳过(仅在未应用时)
226+
if (skipIntroEnabled.value && !skipIntroApplied.value) {
227+
applyIntroSkip()
228+
}
258229

259-
// 应用片尾跳过(仅在未应用时)
260-
if (skipOutroEnabled.value && !skipOutroApplied.value) {
261-
applyOutroSkip()
262-
}
230+
// 应用片尾跳过(仅在未应用时)
231+
if (skipOutroEnabled.value && !skipOutroApplied.value) {
232+
applyOutroSkip()
233+
}
234+
}, 200)
263235
}
264236

265237
/**

0 commit comments

Comments
 (0)