Skip to content

Commit 838d341

Browse files
author
Taois
committed
feat: 修复播放器问题
1 parent 48d45c2 commit 838d341

File tree

6 files changed

+902
-96
lines changed

6 files changed

+902
-96
lines changed

dashboard/src/components/players/ArtVideoPlayer.vue

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<a-card v-if="visible && videoUrl" class="art-video-player-section">
2+
<a-card v-if="visible && videoUrl" class="video-player-section">
33
<PlayerHeader
44
:episode-name="episodeName"
55
:player-type="playerType"
@@ -179,23 +179,24 @@ const isDirectVideoLink = (url) => {
179179
url.toLowerCase().includes('rtmp') ||
180180
url.toLowerCase().includes('rtsp')
181181

182-
// 检查是否看起来像网页链接
182+
// 如果有视频扩展名或是流媒体格式,认为是直链
183+
if (hasVideoExtension || isStreamingFormat) {
184+
return true
185+
}
186+
187+
// 检查是否看起来像网页链接(但排除已经确认为视频的情况)
183188
const looksLikeWebpage = url.includes('://') &&
184189
(url.includes('.html') ||
185190
url.includes('.php') ||
186191
url.includes('.asp') ||
187192
url.includes('.jsp') ||
188-
url.match(/\/[^.]*$/) || // 没有扩展名的路径
189-
url.includes('?') || // 包含查询参数
190-
url.includes('#')) // 包含锚点
191-
192-
// 如果有视频扩展名或是流媒体格式,认为是直链
193-
if (hasVideoExtension || isStreamingFormat) {
194-
return true
195-
}
193+
url.match(/\/[^.?#]*$/) // 没有扩展名且没有查询参数的路径
194+
) &&
195+
!hasVideoExtension &&
196+
!isStreamingFormat
196197

197198
// 如果看起来像网页,认为不是直链
198-
if (looksLikeWebpage && !hasVideoExtension && !isStreamingFormat) {
199+
if (looksLikeWebpage) {
199200
return false
200201
}
201202

@@ -301,9 +302,10 @@ const initArtPlayer = async (url) => {
301302
theme: '#23ade5',
302303
lang: 'zh-cn',
303304
whitelist: ['*'],
304-
moreVideoAttr: {
305-
crossOrigin: 'anonymous',
306-
},
305+
// 移除crossOrigin设置以避免CORS问题
306+
// moreVideoAttr: {
307+
// crossOrigin: 'anonymous',
308+
// },
307309
// 自定义视频类型处理
308310
type: isHLS ? 'm3u8' : '',
309311
// 自定义加载器
@@ -1140,7 +1142,7 @@ onUnmounted(() => {
11401142

11411143
<style scoped>
11421144
/* ArtPlayer 播放器样式 */
1143-
.art-video-player-section {
1145+
.video-player-section {
11441146
margin-bottom: 20px;
11451147
border-radius: 12px;
11461148
overflow: hidden;

dashboard/src/components/players/VideoPlayer.vue

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ const {
181181
skipIntroSeconds,
182182
skipOutroSeconds,
183183
skipEnabled,
184+
skipOutroTimer,
184185
initSkipSettings,
185186
applySkipSettings,
186187
handleTimeUpdate,
@@ -260,23 +261,24 @@ const isDirectVideoLink = (url) => {
260261
url.toLowerCase().includes('rtmp') ||
261262
url.toLowerCase().includes('rtsp')
262263

263-
// 检查是否看起来像网页链接
264+
// 如果有视频扩展名或是流媒体格式,认为是直链
265+
if (hasVideoExtension || isStreamingFormat) {
266+
return true
267+
}
268+
269+
// 检查是否看起来像网页链接(但排除已经确认为视频的情况)
264270
const looksLikeWebpage = url.includes('://') &&
265271
(url.includes('.html') ||
266272
url.includes('.php') ||
267273
url.includes('.asp') ||
268274
url.includes('.jsp') ||
269-
url.match(/\/[^.]*$/) || // 没有扩展名的路径
270-
url.includes('?') || // 包含查询参数
271-
url.includes('#')) // 包含锚点
272-
273-
// 如果有视频扩展名或是流媒体格式,认为是直链
274-
if (hasVideoExtension || isStreamingFormat) {
275-
return true
276-
}
275+
url.match(/\/[^.?#]*$/) // 没有扩展名且没有查询参数的路径
276+
) &&
277+
!hasVideoExtension &&
278+
!isStreamingFormat
277279

278280
// 如果看起来像网页,认为不是直链
279-
if (looksLikeWebpage && !hasVideoExtension && !isStreamingFormat) {
281+
if (looksLikeWebpage) {
280282
return false
281283
}
282284

dashboard/src/router/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Settings from '@/views/Settings.vue';
1010
import BookGallery from '@/views/BookGallery.vue';
1111
import ActionTest from '@/views/ActionTest.vue';
1212
import ActionDebugTest from '@/views/ActionDebugTest.vue';
13+
import VideoTest from '@/views/VideoTest.vue';
1314

1415

1516
const routes = [
@@ -24,6 +25,7 @@ const routes = [
2425
{path: '/parser', component: Parser, name: 'Parser'},
2526
{path: '/action-test', component: ActionTest, name: 'ActionTest'},
2627
{path: '/action-debug-test', component: ActionDebugTest, name: 'ActionDebugTest'},
28+
{path: '/video-test', component: VideoTest, name: 'VideoTest'},
2729

2830
// 404 fallback路由 - 必须放在最后
2931
{path: '/:pathMatch(.*)*', redirect: '/'}

dashboard/src/views/ActionTest.vue

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@
1010
</h1>
1111
<p class="page-subtitle">测试各种Action组件的功能和交互效果</p>
1212
</div>
13-
<a-button type="primary" status="success" @click="goToDebugTest" class="nav-button">
14-
<icon-bug />
15-
综合测试工具
16-
</a-button>
13+
<div class="nav-buttons">
14+
<a-button type="primary" status="success" @click="goToDebugTest" class="nav-button">
15+
<icon-bug />
16+
综合测试工具
17+
</a-button>
18+
<a-button type="primary" status="warning" @click="goToVideoTest" class="nav-button">
19+
<icon-play-arrow />
20+
视频播放测试
21+
</a-button>
22+
</div>
1723
</div>
1824
</div>
1925

@@ -249,7 +255,7 @@
249255
<script>
250256
import { ref, computed, onMounted } from 'vue'
251257
import { useRouter } from 'vue-router'
252-
import { IconCode } from '@arco-design/web-vue/es/icon'
258+
import { IconCode, IconBug, IconPlayArrow } from '@arco-design/web-vue/es/icon'
253259
import {
254260
ActionRenderer,
255261
Actions,
@@ -269,7 +275,9 @@ export default {
269275
name: 'ActionTest',
270276
components: {
271277
ActionRenderer,
272-
IconCode
278+
IconCode,
279+
IconBug,
280+
IconPlayArrow
273281
},
274282
setup() {
275283
const router = useRouter()
@@ -331,6 +339,11 @@ export default {
331339
router.push('/action-debug-test')
332340
}
333341

342+
// 跳转到视频播放测试
343+
const goToVideoTest = () => {
344+
router.push('/video-test')
345+
}
346+
334347
// 格式化时间
335348
const formatTime = (timestamp) => {
336349
return new Date(timestamp).toLocaleTimeString()
@@ -1286,6 +1299,7 @@ export default {
12861299
handleDebugActionError,
12871300
addResult,
12881301
goToDebugTest,
1302+
goToVideoTest,
12891303
formatTime,
12901304
formatResult,
12911305
testInputAction,
@@ -1383,6 +1397,13 @@ export default {
13831397
margin: 0 0 8px 0;
13841398
}
13851399

1400+
.nav-buttons {
1401+
display: flex;
1402+
flex-direction: column;
1403+
gap: 8px;
1404+
align-items: flex-end;
1405+
}
1406+
13861407
.nav-button {
13871408
padding: 8px 16px;
13881409
background: var(--color-primary-6);

dashboard/src/views/VideoDetail.vue

Lines changed: 25 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ const selectEpisode = async (index) => {
924924

925925

926926

927-
const playVideo = () => {
927+
const playVideo = async () => {
928928
// 检查是否有历史记录
929929
const videoId = originalVideoInfo.value.id
930930
const apiUrl = currentSiteInfo.value.api
@@ -944,42 +944,28 @@ const playVideo = () => {
944944
currentRoute.value = routeIndex
945945

946946
// 等待currentRouteEpisodes更新后查找选集
947-
nextTick(() => {
948-
const episodes = currentRouteEpisodes.value
949-
const targetEpisode = episodes.find(ep => ep.name === historyItem.current_episode_name)
950-
951-
if (targetEpisode) {
952-
const episodeIndex = episodes.indexOf(targetEpisode)
953-
currentEpisode.value = episodeIndex
954-
955-
// 等待currentEpisodeUrl更新后播放
956-
nextTick(() => {
957-
if (currentEpisodeUrl.value) {
958-
console.log('播放历史记录位置:', historyItem.current_episode_name)
959-
Message.info(`继续播放: ${historyItem.current_episode_name}`)
960-
961-
// 启动内置播放器
962-
showVideoPlayer.value = true
963-
964-
// 更新历史记录的播放时间
965-
updateHistoryRecord()
966-
}
967-
})
968-
} else {
969-
console.warn('未找到历史选集,播放第一个选集')
970-
playFirstEpisode()
971-
}
972-
})
947+
await nextTick()
948+
const episodes = currentRouteEpisodes.value
949+
const targetEpisode = episodes.find(ep => ep.name === historyItem.current_episode_name)
950+
951+
if (targetEpisode) {
952+
const episodeIndex = episodes.indexOf(targetEpisode)
953+
// 调用selectEpisode进行T4解析
954+
await selectEpisode(episodeIndex)
955+
} else {
956+
console.warn('未找到历史选集,播放第一个选集')
957+
await playFirstEpisode()
958+
}
973959
} else {
974960
console.warn('未找到历史线路,播放第一个选集')
975-
playFirstEpisode()
961+
await playFirstEpisode()
976962
}
977963
} else {
978964
console.log('无历史记录,播放第一个选集')
979-
playFirstEpisode()
965+
await playFirstEpisode()
980966
}
981967
} else {
982-
playFirstEpisode()
968+
await playFirstEpisode()
983969
}
984970
}
985971

@@ -1014,7 +1000,7 @@ const findFirstM3u8Episode = () => {
10141000
return null
10151001
}
10161002

1017-
const playFirstEpisode = () => {
1003+
const playFirstEpisode = async () => {
10181004
// 首先尝试智能查找第一个m3u8选集
10191005
const m3u8Episode = findFirstM3u8Episode()
10201006

@@ -1023,45 +1009,19 @@ const playFirstEpisode = () => {
10231009
console.log(`智能播放m3u8选集: ${m3u8Episode.route} - ${m3u8Episode.episode}`)
10241010
currentRoute.value = m3u8Episode.routeIndex
10251011

1026-
nextTick(() => {
1027-
currentEpisode.value = m3u8Episode.episodeIndex
1028-
1029-
nextTick(() => {
1030-
if (currentEpisodeUrl.value) {
1031-
console.log('播放m3u8选集:', m3u8Episode.episode)
1032-
Message.info(`智能播放: ${m3u8Episode.episode}`)
1033-
1034-
// 启动内置播放器
1035-
showVideoPlayer.value = true
1036-
1037-
// 添加到历史记录
1038-
updateHistoryRecord()
1039-
}
1040-
})
1041-
})
1012+
await nextTick()
1013+
// 调用selectEpisode进行T4解析
1014+
await selectEpisode(m3u8Episode.episodeIndex)
10421015
} else {
10431016
// 未找到m3u8选集,播放第一个线路的第一个选集(默认行为)
10441017
if (playRoutes.value.length > 0) {
10451018
currentRoute.value = 0
10461019

1047-
nextTick(() => {
1048-
if (currentRouteEpisodes.value.length > 0) {
1049-
currentEpisode.value = 0
1050-
1051-
nextTick(() => {
1052-
if (currentEpisodeUrl.value) {
1053-
console.log('播放默认选集:', currentRouteEpisodes.value[0].name)
1054-
Message.info(`开始播放: ${currentRouteEpisodes.value[0].name}`)
1055-
1056-
// 启动内置播放器
1057-
showVideoPlayer.value = true
1058-
1059-
// 添加到历史记录
1060-
updateHistoryRecord()
1061-
}
1062-
})
1063-
}
1064-
})
1020+
await nextTick()
1021+
if (currentRouteEpisodes.value.length > 0) {
1022+
// 调用selectEpisode进行T4解析
1023+
await selectEpisode(0)
1024+
}
10651025
}
10661026
}
10671027
}

0 commit comments

Comments
 (0)