|
@@ -7,24 +7,30 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { onMounted, onBeforeUnmount, watch } from 'vue';
|
|
import { onMounted, onBeforeUnmount, watch } from 'vue';
|
|
|
import flvjs from 'flv.js';
|
|
import flvjs from 'flv.js';
|
|
|
|
|
+ import mpegts from 'mpegts.js';
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
|
url: string;
|
|
url: string;
|
|
|
}>();
|
|
}>();
|
|
|
|
|
|
|
|
- let player: flvjs.Player | null;
|
|
|
|
|
|
|
+ let player: mpegts.Player | null;
|
|
|
|
|
|
|
|
const initPlay = () => {
|
|
const initPlay = () => {
|
|
|
const videoElement = document.getElementById('video') as HTMLMediaElement;
|
|
const videoElement = document.getElementById('video') as HTMLMediaElement;
|
|
|
- player = flvjs.createPlayer({
|
|
|
|
|
- type: 'flv',
|
|
|
|
|
- isLive: true,
|
|
|
|
|
- hasAudio: false,
|
|
|
|
|
- url: props.url,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ player = mpegts.createPlayer(
|
|
|
|
|
+ {
|
|
|
|
|
+ type: 'flv',
|
|
|
|
|
+ isLive: true,
|
|
|
|
|
+ hasAudio: false,
|
|
|
|
|
+ url: props.url,
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ liveBufferLatencyChasing: true,
|
|
|
|
|
+ },
|
|
|
|
|
+ );
|
|
|
player.attachMediaElement(videoElement);
|
|
player.attachMediaElement(videoElement);
|
|
|
player.load();
|
|
player.load();
|
|
|
- player.on(flvjs.Events.METADATA_ARRIVED, () => {
|
|
|
|
|
|
|
+ player.on(flvjs.Events.MEDIA_INFO, () => {
|
|
|
// testStore.setVideoReady(true);
|
|
// testStore.setVideoReady(true);
|
|
|
});
|
|
});
|
|
|
// player.play();
|
|
// player.play();
|