| | |
| | | <template> |
| | | <div> |
| | | <div class="root"> |
| | | <div class="container-shell"> |
| | | <div class="container-shell-title">jessibuca demo player</div> |
| | | <div id="container" ref="container"></div> |
| | | <div class="input"> |
| | | <div>输入URL:</div> |
| | | <input type="input" autocomplete="on" :value="playUrl" /> |
| | | <button v-if="!playing" @click="play">播放</button> |
| | | <button v-else @click="pause">停止</button> |
| | | </div> |
| | | <div class="input" v-if="loaded"> |
| | | <button @click="destroy">销毁</button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <div id="container" ref="container" :style="{width,height}"></div> |
| | | </template> |
| | | |
| | | <script setup lang="ts"> |
| | | import { onMounted, onUnmounted, ref } from 'vue' |
| | | import Jessibuca from '../../../types/jessibuca' |
| | | let jessibuca :null | Jessibuca = null |
| | | import { onMounted, onUnmounted, ref, defineProps, defineEmits } from 'vue' |
| | | import Jessibuca from '../../../public/jessibuca/jessibuca' |
| | | const props = defineProps({ |
| | | videoUrl: { |
| | | type: String, |
| | | required: true |
| | | }, |
| | | width: { |
| | | type: String, |
| | | default: '300px' |
| | | }, |
| | | height: { |
| | | type: String, |
| | | default: '200px' |
| | | } |
| | | }) |
| | | const emits = defineEmits(['timeout']) |
| | | let jessibuca: null | Jessibuca = null |
| | | const container = ref(null) |
| | | const buffer = ref(null) |
| | | const showBandwidth = ref(false) |
| | | const showOperateBtns = ref(false) |
| | | const showOperateBtns = ref(true) |
| | | const forceNoOffscreen = ref(false) |
| | | const playUrl = ref('http://flv.bdplay.nodemedia.cn/live/bbb.flv') |
| | | // const playUrl = ref() |
| | | const playing = ref(false) |
| | | const quieting = ref(true) |
| | | const loaded = ref(false) |
| | |
| | | text: '', |
| | | // background: "bg.jpg", |
| | | loadingText: '加载中', |
| | | controlAutoHide: true, |
| | | // hasAudio:false, |
| | | debug: true, |
| | | showBandwidth: showBandwidth.value, // 显示网速 |
| | |
| | | }) |
| | | |
| | | jessibuca.on('error', function (error: any) { |
| | | console.log('error', error) |
| | | console.error('error', error) |
| | | }) |
| | | |
| | | jessibuca.on('timeout', function () { |
| | | console.log('timeout') |
| | | emits('timeout') |
| | | }) |
| | | |
| | | jessibuca.on('start', function () { |
| | |
| | | } |
| | | onMounted(() => { |
| | | createJessibuca() |
| | | play() |
| | | }) |
| | | onUnmounted(() => { |
| | | jessibuca && jessibuca.destroy() |
| | | }) |
| | | const play = () => { |
| | | if (playUrl.value) { |
| | | jessibuca?.play(playUrl.value) |
| | | if (props.videoUrl) { |
| | | jessibuca?.play(props.videoUrl) |
| | | } |
| | | } |
| | | const pause = () => { |
| | |
| | | } |
| | | </script> |
| | | |
| | | <style scoped></style> |
| | | <style scoped lang="scss"></style> |