123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <template>
- <div
- :class="[
- 'video-wrapper',
- isMobile ? 'mobile' : '',
- isCssFullScreenRef ? 'fullScreen' : '',
- ]"
- :style="{ minHeight: props.height }"
- >
- <div id="mse"></div>
- <Transition name="fade">
- <div v-show="questionShowRef && question" class="question">
- 问题:{{ question }}
- </div>
- </Transition>
- <Transition name="fade">
- <div
- v-show="questionShowRef"
- :class="['option-btn-box']"
- :style="{ flexWrap: props.options.length >= 4 ? 'wrap' : 'nowrap' }"
- >
- <div
- class="option-btn-item"
- v-for="(option, index) in props.options"
- :key="index"
- >
- <div class="option-btn" @click="() => emits('onClickOption', option)">
- {{ option.optionType }}:{{ option.optionName }}
- </div>
- </div>
- </div>
- </Transition>
- </div>
- </template>
- <script>
- export default {
- name: "VideoLineGraph",
- };
- </script>
- <script setup>
- import { watch } from "vue";
- import useInitPlayer from "./hooks/useInitPlayer";
- const emits = defineEmits("onClickOption", "onFullscreenChange", 'reload');
- const props = defineProps({
-
- question: {
- type: String,
- default: "",
- },
-
- options: {
- type: Array,
- default: () => [],
- },
-
- videoUrl: {
- type: String,
- default: "",
- },
-
- width: {
- type: String,
- default: "100%",
- },
-
- height: {
- type: String,
- default: "80vh",
- },
-
- autoplay: {
- type: Boolean,
- default: true,
- },
-
- autoplayMuted: {
- type: Boolean,
- default: false,
- },
-
- poster: {
- type: String,
- default: "",
- },
-
- ifSendMsg: {
- type: Boolean,
- default: false,
- },
-
- pipData: {
- type: Object,
- default: () => ({}),
- },
- });
- const { xgplayer, isMobile, isCssFullScreenRef, questionShowRef, playNext } =
- useInitPlayer(props, emits);
- watch(
- () => props.videoUrl,
- (value) => {
- if (!xgplayer.value || !props.videoUrl) return;
- playNext(value, props.poster);
-
- const posterDom = document.querySelector(".xgplayer-poster");
- posterDom.style.backgroundImage = `url("${props.poster}")`;
- }
- );
- </script>
- <style lang="scss">
- .xgplayer .xgplayer-replay {
- left: unset;
- right: 0;
- top: -20px;
- flex-direction: row;
- width: 110px;
- transform: translate(-20%, 0%);
- }
- .xgplayer.xgplayer-rotate-fullscreen {
- width: 100vh !important;
- }
- </style>
- <style lang="scss" scoped>
- .fade-enter-active {
- transition: opacity 0.8s ease;
- }
- .fade-enter-from {
- opacity: 0;
- }
- .video-wrapper {
- width: 100%;
- background: #999;
- position: relative;
- .question {
- width: 100%;
- position: absolute;
- padding: 8px 16px;
- top: 20%;
- left: 0;
- transform: translateY(-50%);
- background-color: rgba($color: #000000, $alpha: 0.6);
- color: #fff;
- font-size: 14px;
- font-weight: 600;
- z-index: 9999;
- }
- .option-btn-box {
- width: 100%;
- position: absolute;
- bottom: 60px;
- left: 0;
- display: flex;
- z-index: 9999;
- .option-btn-item {
- width: 50%;
- padding: 2px;
- .option-btn {
- border: 1px solid #000;
- background-color: rgba($color: #ffffff, $alpha: 0.6);
- color: #000;
- font-size: 8px;
- width: 100%;
- height: 28px;
- display: flex;
- align-items: center;
- justify-content: flex-start;
- padding: 0 2px;
- user-select: none;
- cursor: pointer;
- }
- }
- }
- &.fullScreen .option-btn-box,
- &.fullScreen .question {
- position: fixed;
- }
- &.mobile.fullScreen .question {
- position: fixed;
- left: 0;
- top: 0;
- width: 100vh;
- transform: rotate(90deg) translate(0, -85vw);
- transform-origin: 0 0;
- }
- &.mobile.fullScreen .option-btn-box {
- left: 0;
- bottom: 0;
- position: fixed;
- transform: rotate(90deg) translate(-100%, -60px);
- transform-origin: 0 100%;
- width: 100vh;
- }
- }
- </style>
|