vue video播放m3u8监控视频

news/2024/10/23 6:13:22/

很关键的问题 vite创建的项目不需要import ‘videojs-contrib-hls’ 导入就报错

直接添加如下代码即可

  html5: {vhs: {overrideNative: true},nativeVideoTracks: false,nativeAudioTracks: false,nativeTextTracks: false}

下面是完整组件示例 

<template><div><videostyle="border-radius: 8px; margin: 0 auto; overflow: hidden"id="my-video"class="video-js vjs-default-skin"controlsautoplaymutedpreload="auto"width="300"ref="videoPlayer"></video></div>
</template><script setup>import { ref, onMounted, onBeforeUnmount, watch } from 'vue';import videojs from 'video.js';import 'video.js/dist/video-js.css';const props = defineProps({srcUrl: {type: String,required: true}});const videoPlayer = ref(null);let player = null;const getVideo = () => {console.log('11111111');player = videojs(videoPlayer.value,{bigPlayButton: true,textTrackDisplay: false,posterImage: false,errorDisplay: false,controlBar: true,html5: {vhs: {overrideNative: true},nativeVideoTracks: false,nativeAudioTracks: false,nativeTextTracks: false}},function onPlayerReady() {console.log('视频加载成功');this.src({ type: 'application/x-mpegURL', src: props.srcUrl });this.play();});};onMounted(() => {getVideo();});watch(() => props.srcUrl,(newSrcUrl) => {if (player) {player.src({ type: 'application/x-mpegURL', src: newSrcUrl });player.play();}});onBeforeUnmount(() => {if (player) {player.dispose();}});
</script><style scoped>video {border-radius: 8px;margin-bottom: 24px;}
</style>

 


http://www.ppmy.cn/news/1541251.html

相关文章

【C++篇】深度解析类与对象(上)

目录 引言 一、类的定义 1.1类定义的基本格式 1.2 成员命名规范 1.3 class与struct的区别 1.4 访问限定符 1.5 类的作用域 二、实例化 2.1 类的实例化 2.2 对象的大小与内存对齐 三、this 指针 3.1 this指针的基本用法 3.2 为什么需要this指针&#xff1f; 3.3 t…

新手学STM32的话,先学标准库还是HAL库?

大家好&#xff0c;我是麦鸽&#xff0c;最近有网友提问 用STM32的话&#xff0c;是学标准库还是HAL库&#xff1f; 对于新手&#xff0c;我想说&#xff0c;不要和自己过不去&#xff0c;一开始不要搞得太难&#xff0c;要循序渐进。 新手经常会问的问题&#xff0c;先学51还是…

88.【C语言】文件操作(5)

目录 文件的随机读写 1.fseek函数 代码示例 运行结果 2.ftell函数 代码示例 运行结果 3.rewind函数 代码示例 运行结果 承接79.【C语言】文件操作(4)文章 文件的随机读写 1.fseek函数 声明:int fseek ( FILE * stream, long int offset, int origin ); 格式:fsee…

itext自定义pdf

pom坐标 <!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf --><dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.5.13.3</version></dependency>字体文件可以…

go 包相关知识

在Go语言中&#xff0c;包的引用和搜索路径是由环境变量GOPATH和GO111MODULE共同决定的。 GOPATH环境变量&#xff1a;这个变量定义了默认的工作目录&#xff0c;Go命令行工具将会在这个目录下查找包文件。这个目录通常包含三个子目录&#xff1a;src、bin和pkg。 src目录包含…

解决Eclipse中’Run As’菜单缺少’Run on Server’选项的问题

解决Eclipse中’Run As’菜单缺少’Run on Server’选项的问题 问题描述&#xff1a; 当您在Eclipse中导入一个Web项目后&#xff0c;可能会发现在’Run As’菜单中没有’Run on Server’选项。这可能会让您无法方便地在本地服务器上运行和调试Web应用程序。 可能原因&#…

Qml-CheckBox的使用

Qml-CheckBox的使用 CheckBox属性 CheckBox的继承关系&#xff1a; CheckBox – AbstractButton – Control – Item; CheckBox的属性主要继承于AbstractButton。属性checkState&#xff1a;勾选状态&#xff0c;值为&#xff1a;Qt.Unchecked、Qt.Checked、Qt.PartiallyChec…

iOS弹出系统相册选择弹窗

直接上代码 if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {UIImagePickerController *imagePickerController [[UIImagePickerController alloc] init];imagePickerController.delegate self; //设置代理imagePicke…