|
|
|
@ -7,15 +7,9 @@
|
|
|
|
|
<RedoOutlined title="刷新" @click="reloadLive" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="player">
|
|
|
|
|
<video
|
|
|
|
|
id="player-container-original-live"
|
|
|
|
|
width="480"
|
|
|
|
|
height="340"
|
|
|
|
|
preload="auto"
|
|
|
|
|
playsinline
|
|
|
|
|
webkit-playsinline
|
|
|
|
|
>
|
|
|
|
|
</video>
|
|
|
|
|
<div class="video-content">
|
|
|
|
|
<video id="player-container-original-live" class="video-player" controls></video>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="testing-video">
|
|
|
|
@ -25,25 +19,18 @@
|
|
|
|
|
<RedoOutlined title="刷新" @click="reloadTestingLive" />
|
|
|
|
|
</div>
|
|
|
|
|
<div class="player">
|
|
|
|
|
<video
|
|
|
|
|
id="player-container-testing-live"
|
|
|
|
|
width="480"
|
|
|
|
|
height="340"
|
|
|
|
|
preload="auto"
|
|
|
|
|
playsinline
|
|
|
|
|
webkit-playsinline
|
|
|
|
|
>
|
|
|
|
|
</video>
|
|
|
|
|
<div class="video-content">
|
|
|
|
|
<video id="player-container-testing-live" class="video-player" controls></video>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import TCPlayer from 'tcplayer.js';
|
|
|
|
|
import 'tcplayer.js/dist/tcplayer.min.css'; //引入插件和样式文件
|
|
|
|
|
import { airPortStore } from '@/store/modules/airport';
|
|
|
|
|
import { onMounted, watch, onBeforeUnmount } from 'vue';
|
|
|
|
|
import { VideoCameraOutlined, RedoOutlined } from '@ant-design/icons-vue';
|
|
|
|
|
import flvjs from 'flv.js';
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
statisData: {
|
|
|
|
@ -58,38 +45,57 @@
|
|
|
|
|
let player;
|
|
|
|
|
const liveCode = live_info.url + '7.flv';
|
|
|
|
|
const playVideo = () => {
|
|
|
|
|
player = TCPlayer('player-container-original-live', {
|
|
|
|
|
sources: [
|
|
|
|
|
{
|
|
|
|
|
src: liveCode, // 播放地址
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
licenseUrl: liveCode, // license 地址,必传。参考准备工作部分,在视立方控制台申请 license 后可获得 licenseUrl
|
|
|
|
|
var originalElement = document.getElementById('player-container-original-live');
|
|
|
|
|
var player = flvjs.createPlayer({
|
|
|
|
|
type: 'flv',
|
|
|
|
|
url: liveCode,
|
|
|
|
|
});
|
|
|
|
|
player.attachMediaElement(originalElement);
|
|
|
|
|
player.load();
|
|
|
|
|
player.play();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 检测后流
|
|
|
|
|
let playerTesting;
|
|
|
|
|
const testingCode = live_info.url + '11.flv';
|
|
|
|
|
const testingPlayVideo = () => {
|
|
|
|
|
player = TCPlayer('player-container-testing-live', {
|
|
|
|
|
sources: [
|
|
|
|
|
{
|
|
|
|
|
src: testingCode, // 播放地址
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
licenseUrl: testingCode, // license 地址,必传。参考准备工作部分,在视立方控制台申请 license 后可获得 licenseUrl
|
|
|
|
|
var testingElement = document.getElementById('player-container-testing-live');
|
|
|
|
|
var playerTesting = flvjs.createPlayer({
|
|
|
|
|
type: 'flv',
|
|
|
|
|
url: testingCode,
|
|
|
|
|
});
|
|
|
|
|
playerTesting.attachMediaElement(testingElement);
|
|
|
|
|
playerTesting.load();
|
|
|
|
|
playerTesting.play();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const reloadLive = () => {
|
|
|
|
|
player.src(liveCode);
|
|
|
|
|
player.play();
|
|
|
|
|
var originalElement = document.getElementById('player-container-original-live');
|
|
|
|
|
if (player) {
|
|
|
|
|
player.detachMediaElement(); // 断开当前元素
|
|
|
|
|
player.destroy(); // 销毁播放器实例
|
|
|
|
|
player = flvjs.createPlayer({
|
|
|
|
|
type: 'flv',
|
|
|
|
|
url: liveCode,
|
|
|
|
|
});
|
|
|
|
|
player.attachMediaElement(originalElement); // 重新绑定 video 元素
|
|
|
|
|
player.load(); // 加载视频
|
|
|
|
|
player.play(); // 播放视频
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const reloadTestingLive = () => {
|
|
|
|
|
var testingElement = document.getElementById('player-container-testing-live');
|
|
|
|
|
|
|
|
|
|
if (playerTesting) {
|
|
|
|
|
playerTesting.src(testingCode);
|
|
|
|
|
playerTesting.play();
|
|
|
|
|
playerTesting.detachMediaElement(); // 断开当前元素
|
|
|
|
|
player.destroy(); // 销毁播放器实例
|
|
|
|
|
playerTesting = flvjs.createPlayer({
|
|
|
|
|
type: 'flv',
|
|
|
|
|
url: testingCode,
|
|
|
|
|
});
|
|
|
|
|
playerTesting.attachMediaElement(testingElement); // 重新绑定 video 元素
|
|
|
|
|
playerTesting.load(); // 加载视频
|
|
|
|
|
playerTesting.play(); // 播放视频
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
onMounted(() => {
|
|
|
|
@ -155,4 +161,9 @@
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
.video-player {
|
|
|
|
|
margin: 6px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 32vh;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|