Просмотр исходного кода

1、视频添加边框
2、解决自动暂停视频背景bug

丸子 1 неделя назад
Родитель
Сommit
5dffdf7b33
1 измененных файлов с 69 добавлено и 36 удалено
  1. 69 36
      src/views/AIPage/aiGenerate/DialogContent.vue

+ 69 - 36
src/views/AIPage/aiGenerate/DialogContent.vue

@@ -70,15 +70,19 @@
 
       <!-- 视频显示区域 -->
       <div v-if="currentDialogue && currentDialogue.type === 'video'" class="video-display">
-        <video
-          :src="currentDialogue.videoUrl"
-          class="dialogue-video"
-          controls
-          autoplay
-          @ended="handleVideoEnded"
-        >
-          您的浏览器不支持视频播放
-        </video>
+        <div class="video-frame">
+          <video
+            :src="currentDialogue.videoUrl"
+            class="dialogue-video"
+            controls
+            autoplay
+            @ended="handleVideoEnded"
+            @contextmenu.prevent
+            controlslist="nodownload"
+          >
+            您的浏览器不支持视频播放
+          </video>
+        </div>
       </div>
 
       <!-- 用户输入卡片 -->
@@ -130,9 +134,21 @@
     </div>
 
     <!-- 背景图 -->
-    <img v-if="currentBackgroundType === 'imageAudio'" :src="currentBackgroundImage" alt="背景图" class="background-image">
+    <img 
+      v-if="currentBackgroundType === 'imageAudio'" 
+      :src="currentBackgroundImage" 
+      alt="背景图" 
+      class="background-image"
+    >
     <!-- 背景视频 -->
-    <video v-else-if="currentBackgroundType === 'video'" ref="backgroundVideoRef" :src="currentBackgroundVideo" class="background-video" loop muted playsinline>
+    <video 
+      v-else-if="currentBackgroundType === 'video'"  
+      ref="backgroundVideoRef" 
+      :src="currentBackgroundVideo" 
+      class="background-video"  
+      loop 
+      muted 
+      playsinline>
       您的浏览器不支持视频播放
     </video>
   </div>
@@ -225,6 +241,7 @@ const currentBackgroundImage = computed(() => {
   return currentSection.value.backgroundImage.url
 })
 
+
 // 当前背景类型
 const currentBackgroundType = computed(() => {
   return currentSection.value?.backgroundType || 'imageAudio'
@@ -331,9 +348,6 @@ const stopAllAudio = () => {
     dialogueAudio.value.pause()
     dialogueAudio.value.currentTime = 0
   }
-  if (backgroundVideoRef.value) {
-    backgroundVideoRef.value.pause()
-  }
 }
 
 const playBackgroundAudio = () => {
@@ -352,14 +366,11 @@ const playBackgroundAudio = () => {
   }
 
   // 处理背景视频
-  if (currentBackgroundType.value === 'video' && isPlaybackStarted.value && isPlaying.value) {
+  if (currentBackgroundType.value === 'video' && isPlaybackStarted.value) {
     // 视频已经在模板中渲染,这里只需要确保它在播放状态
     if (backgroundVideoRef.value) {
       backgroundVideoRef.value.play().catch(e => console.error('背景视频播放失败:', e))
     }
-  } else if (backgroundVideoRef.value) {
-    // 暂停视频
-    backgroundVideoRef.value.pause()
   }
 }
 
@@ -458,16 +469,12 @@ const togglePlay = () => {
   if (isPlaying.value) {
     // 播放背景音
     playBackgroundAudio()
-    // 继续播放背景视频
-    if (backgroundVideoRef.value) {
-      backgroundVideoRef.value.play().catch(e => console.error('背景视频播放失败:', e))
-    }
     if(!getIsPlaying() && !conversationInProgress.value){
       // 开始播放序列
       playSequence()
     }
   } else {
-    // 暂停所有音频和视频
+    // 暂停所有音频
     stopAllAudio()
   }
 }
@@ -1889,7 +1896,6 @@ onUnmounted(() => {
   display: flex;
   align-items: center;
   justify-content: center;
-  //flex-direction: column;
   text-align: center;
   transition: all 0.5s ease-in-out;
 }
@@ -1914,16 +1920,36 @@ onUnmounted(() => {
   position: absolute;
   top: 45%;
   left: 50%;
-  transform: translate(-50%, -50%);
+  transform: translate(-50%, -50%) scale(0.8);
   z-index: 5;
-  width: 65%;
+  width: 100%;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  opacity: 0;
+  animation: videoFadeIn 0.8s ease-out forwards;
+}
+
+.video-frame {
+  width: rpx(420);
+  height: rpx(250);
+  padding: rpx(5);
+  background: linear-gradient(135deg, rgba(160, 220, 240, 0.8), rgba(80, 190, 240, 0.8));
+  border: rpx(2) solid rgba(0, 100, 192, 0.8);
+  border-radius: rpx(15);
+  box-shadow: 0 rpx(8) rpx(25) rgba(0, 0, 0, 0.4);
+  backdrop-filter: blur(rpx(5));
+  display: flex;
+  justify-content: center;
+  align-items: center;
 }
 
 .dialogue-video {
   width: 100%;
   height: 100%;
   border-radius: rpx(10);
-  box-shadow: 0 rpx(5) rpx(15) rgba(0, 0, 0, 0.2);
+  background-color: #000;
+  object-fit: contain;
 }
 
 .poem-text::before {
@@ -1933,7 +1959,6 @@ onUnmounted(() => {
   left: 0;
   right: 0;
   bottom: 0;
-  // background: linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0) 100%);
   animation: poemShine 3s ease-in-out infinite;
 }
 
@@ -1959,14 +1984,6 @@ onUnmounted(() => {
   }
 }
 
-// @keyframes poemShine {
-//   0% {
-//     transform: translateX(-100%) rotate(45deg);
-//   }
-//   100% {
-//     transform: translateX(100%) rotate(45deg);
-//   }
-// }
 
 .poem-text p {
   margin: rpx(10) 0;
@@ -2006,4 +2023,20 @@ onUnmounted(() => {
     transform: translateY(0);
   }
 }
+
+// 对话视频显示动画
+@keyframes videoFadeIn {
+  0% {
+    opacity: 0;
+    transform: translate(-50%, -50%) scale(0.8);
+  }
+  70% {
+    opacity: 1;
+    transform: translate(-50%, -50%) scale(1.05);
+  }
+  100% {
+    opacity: 1;
+    transform: translate(-50%, -50%) scale(1);
+  }
+}
 </style>