我们在写cesium项目时,可能会想到先播放一段视频再加载出我们真正的页面,那么应该如何做呢?其实做法很简单。
附上代码实例
<template>
<!-- 视频播放器 -->
<video id="introVideo" controls autoplay style="width: 100%; height: 100%;" v-if="!videoEnded">
<source src="https://tb-video.bdstatic.com/tieba-smallvideo-transcode-crf/8596830_a86ed6c56bbac726673851575079051a_1e6e55ebbf32_0.mp4?vt=1&pt=3&ver=&cr=2&cd=0&sid=&ft=8&tbau=2024-03-10_76a8e91a64ff1c0aae63dba2cdacd7d60d05e8d341b9d90ec97233170761937c&ptid=8311645316">
<!-- 添加其他视频格式的源,以确保在不同浏览器中的兼容性 -->
Your browser does not support the video tag.
</video>
<div id="cesiumContainer"></div>
</template>
<script setup>
import * as Cesium from 'cesium';
// 标记视频是否结束
const videoEnded = ref(false);
// 初始化cesium,全局挂载viewer和handler