diff --git a/pages/index/startPage.vue b/pages/index/startPage.vue
index 115b670..4ccff6c 100644
--- a/pages/index/startPage.vue
+++ b/pages/index/startPage.vue
@@ -20,6 +20,7 @@
@loadedmetadata="onVideoMetadata"
@canplay="onVideoReady"
@play="onVideoReady"
+ @timeupdate="onVideoTimeUpdate"
@ended="onVideoEnded"
@click="onMediaClick"
/>
@@ -33,10 +34,10 @@
@click="onMediaClick"
/>
- {{ `跳过 ${countDown}s` }}
+ {{ getSkipText() }}
- {{ `跳过 ${countDown}s` }}
+ {{ getSkipText() }}
@@ -47,7 +48,7 @@ import * as IndexApi from '@/sheep/api/index/index'
const USE_STATIC_START_PAGE = false
const DEFAULT_IMAGE_SECONDS = 3
-const MAX_VIDEO_SECONDS = 15
+const MAX_VIDEO_SECONDS = 9
const bgSrc = ref('')
const jumpUrl = ref('')
@@ -57,6 +58,7 @@ let downloadToken = 0
let readyFallbackTimer = null
let countDownTimer = null
let jumpTimer = null
+let videoCountdownBootTimer = null
const normalizeAppFileUrl = (path) => {
const p = String(path || '')
@@ -127,7 +129,12 @@ function onMediaError() {
startCountDown(DEFAULT_IMAGE_SECONDS)
}
-const countDown = ref(DEFAULT_IMAGE_SECONDS)
+const countDown = ref(0)
+
+const getSkipText = () => {
+ const s = Number(countDown.value) || 0
+ return s > 0 ? `跳过 ${s}s` : '跳过'
+}
function closeNativeSplashIfNeeded() {
try {
@@ -144,6 +151,8 @@ function clearTimers() {
countDownTimer = null
if (jumpTimer) clearTimeout(jumpTimer)
jumpTimer = null
+ if (videoCountdownBootTimer) clearTimeout(videoCountdownBootTimer)
+ videoCountdownBootTimer = null
}
function startCountDown(seconds) {
@@ -182,13 +191,21 @@ function onVideoReady() {
mediaReady.value = true
closeNativeSplashIfNeeded()
}
- if (!countDownTimer) {
+ if (countDownTimer) return
+ if (videoCountdownBootTimer) return
+ videoCountdownBootTimer = setTimeout(() => {
+ videoCountdownBootTimer = null
+ if (countDownTimer) return
startCountDown(MAX_VIDEO_SECONDS)
scheduleJumpAfter(MAX_VIDEO_SECONDS + 0.2)
- }
+ }, 300)
}
function onVideoMetadata(e) {
+ if (videoCountdownBootTimer) {
+ clearTimeout(videoCountdownBootTimer)
+ videoCountdownBootTimer = null
+ }
if (!mediaReady.value) {
mediaReady.value = true
closeNativeSplashIfNeeded()
@@ -199,6 +216,20 @@ function onVideoMetadata(e) {
scheduleJumpAfter(limit + 0.2)
}
+function onVideoTimeUpdate(e) {
+ const duration = Number(e?.detail?.duration || e?.detail?.totalTime || 0)
+ if (!Number.isFinite(duration) || duration <= 0) return
+ const limit = Math.min(MAX_VIDEO_SECONDS, Math.ceil(duration))
+ if (countDown.value === limit) return
+ if (countDownTimer && countDown.value < MAX_VIDEO_SECONDS) return
+ if (videoCountdownBootTimer) {
+ clearTimeout(videoCountdownBootTimer)
+ videoCountdownBootTimer = null
+ }
+ startCountDown(limit)
+ scheduleJumpAfter(limit + 0.2)
+}
+
function onVideoEnded() {
toHome()
}
@@ -274,18 +305,22 @@ function onMediaClick() {
position: absolute;
top: calc(env(safe-area-inset-top) + 100rpx);
right: 60rpx;
- padding: 18rpx 20rpx;
+ height: 64rpx;
+ padding: 0 20rpx;
border-radius: 50rpx;
font-size: 28rpx;
- line-height: 1;
+ line-height: 32rpx;
color: #fff;
background: rgba(0, 0, 0, 0.4);
z-index: 9999;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
.count-down-text {
color: #fff;
font-size: 28rpx;
- line-height: 1;
+ line-height: 32rpx;
}