123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- <template>
- <div class="monitor" :style="{ height: height + 'px', width: width + 'px' }" >
- <div class="main-video">
- <video
- :src="selectedVideo"
- controls
- @play="handlePlay"
- :width="width*2/3"
- :height="height*2/3"
- autoplay
- ></video>
- <!--{{selectedVideo}}-->
- </div>
- <div class="video-list">
- <div
- v-for="(video, index) in videoList"
- :key="index"
- class="video-item"
- :class="{ active: video === (selectedVideo || videoList[0]) }"
- @click="selectVideo(video)"
- >
- <img :src="imgList[index]" alt="" />
- <div class="video-title">{{ getTitleFromPath(video) }}</div>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: "viewMonitor",
- props: {
- height: {
- type: Number,
- default: 800,
- },
- width: {
- type: Number,
- default: 1200,
- },
- },
- data() {
- return {
- videoList: [require("../assets/video/monitor1.mp4"), require("../assets/video/GrassMontior.mp4")],
- imgList: [
- require("../assets/imgs/bg.jpg"),
- require("../assets/imgs/bg.jpg"),
- ],
- selectedVideo: require("../assets/video/monitor1.mp4"),//没用
- };
- },
- methods: {
- selectVideo(video) {
- this.selectedVideo = video;
- },
- getTitleFromPath(path) {
- return path.split("/").pop().split(".")[0];
- },
- handlePlay() {
- // 可以在这里实现其他功能,如统计播放次数等
- },
- },
- };
- </script>
- <style>
- .monitor {
- display: flex;
- gap: 20px;
- padding: 20px;
- }
- .main-video {
- width: 70%;
- max-width: 2000px;
- }
- .video-list {
- transform: translateY(10%);
- width: 30%;
- max-width: 800px;
- display: flex;
- flex-direction: column;
- gap: 10px;
- }
- .video-item {
- display: flex;
- align-items: center;
- gap: 10px;
- padding: 10px;
- background-color: rgba(0, 0, 0, 0.1);
- border-radius: 5px;
- cursor: pointer;
- }
- .video-item.active {
- opacity: 0.5;
- }
- .video-item img {
- width: 100px;
- height: 60px;
- object-fit: cover;
- }
- .video-title {
- font-weight: bold;
- flex: 1;
- text-align: left;
- }
- </style>
|