|
@@ -0,0 +1,508 @@
|
|
|
+<template>
|
|
|
+ <!-- <el-container>
|
|
|
+ <el-row>
|
|
|
+ <el-input v-model="code" placeholder="输入监控点编码" @change="onChangeCode"></el-input>
|
|
|
+ <el-button @click="onSubmit">默认预览</el-button>
|
|
|
+ <el-button @click="onTwoSubmit(2)">4分屏</el-button>
|
|
|
+ <el-button @click="onTwoSubmit(4)">16分屏</el-button>
|
|
|
+ <el-button @click="onTwoSubmit(8)">64分屏</el-button>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <div id="player" style="width: 800px;height: 800px;"></div>
|
|
|
+ </el-row>
|
|
|
+ </el-container> -->
|
|
|
+ <div :id="`player${option.id}`"></div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ name:"VideoPlayer",
|
|
|
+ props:{
|
|
|
+ option: {
|
|
|
+ id: {
|
|
|
+ type: String,
|
|
|
+ default: ""
|
|
|
+ },
|
|
|
+ url:{
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ beginTime:{
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ endTime:{
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ width:{
|
|
|
+ type: String,
|
|
|
+ default: '784px'
|
|
|
+ },
|
|
|
+ height:{
|
|
|
+ type: String,
|
|
|
+ default: '440px'
|
|
|
+ },
|
|
|
+ split:{
|
|
|
+ type:Number,
|
|
|
+ default:1
|
|
|
+ },
|
|
|
+ index:{
|
|
|
+ type:Number,
|
|
|
+ default:0
|
|
|
+ },
|
|
|
+ },
|
|
|
+ playback: {
|
|
|
+ startTime:{
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ endTime:{
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ seekStart:{
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ rate: {
|
|
|
+ type: String,
|
|
|
+ default: ''
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ player: null,
|
|
|
+ count: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$el.style.setProperty('display', 'block');
|
|
|
+ this.$el.style.setProperty('width', this.option.width||"784px");
|
|
|
+ this.$el.style.setProperty('height', this.option.height||"440px");
|
|
|
+ // this.initPlayer(this.option);
|
|
|
+ // this.play(this.option);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // watch:{
|
|
|
+ // option(){
|
|
|
+ // if(this.option){
|
|
|
+ // this.play(this.option);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
+ methods: {
|
|
|
+ initPlayer(option) {
|
|
|
+ // 设置播放容器的宽高并监听窗口大小变化
|
|
|
+ window.addEventListener('resize', () => {
|
|
|
+ this.player.JS_Resize()
|
|
|
+ })
|
|
|
+ this.player = new window.JSPlugin({
|
|
|
+ // 需要英文字母开头 必填,
|
|
|
+ szId: 'player'+option.id,
|
|
|
+ // 必填,引用H5player.min.js的js相对路径
|
|
|
+ szBasePath: '/src/H5player/bin/h5player.min.js',
|
|
|
+ // 当容器div#play_window有固定宽高时,可不传iWidth和iHeight,窗口大小将自适应容器宽高
|
|
|
+ // iWidth: 600,
|
|
|
+ // iHeight: 400,
|
|
|
+ // 分屏播放,默认最大分屏4*4
|
|
|
+ iMaxSplit: 4,
|
|
|
+ iCurrentSplit: option.split,
|
|
|
+ openDebug:false,
|
|
|
+ // 样式
|
|
|
+ oStyle: {
|
|
|
+ border: '#343434',
|
|
|
+ borderSelect: '#FFCC00',
|
|
|
+ background: '#000'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ play(option,callback) {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ const param = {
|
|
|
+ playURL: option.url,
|
|
|
+ mode: 1
|
|
|
+ }
|
|
|
+ let index = option.index;
|
|
|
+ if(option.beginTime&&option.endTime) {
|
|
|
+ this.player.JS_Play(option.url, param, index,option.beginTime,option.endTime).then(() => {
|
|
|
+ // 播放成功回调
|
|
|
+ resolve(true);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ resolve(false);
|
|
|
+ console.log('播放失败')
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.player.JS_Play(option.url,param,index).then(() => {
|
|
|
+ resolve(true);
|
|
|
+ },(err) => {
|
|
|
+ resolve(false);
|
|
|
+ console.log("play fail");
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ /* console.log(option);
|
|
|
+ const _this = this;
|
|
|
+ const param = { playURL: option.url,mode: 1};
|
|
|
+ var index=option.index||0;
|
|
|
+ // if (!index) {
|
|
|
+ // index = 0
|
|
|
+ // }
|
|
|
+ if(option.beginTime&&option.endTime){
|
|
|
+ _this.player.JS_Play(option.url, param, index,option.beginTime,option.endTime).then(() => {
|
|
|
+ // 播放成功回调
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log('播放失败')
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ _this.player.JS_Play(option.url, param, index).then(() => {
|
|
|
+ // 播放成功回调
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.log('播放失败')
|
|
|
+ });
|
|
|
+ } */
|
|
|
+
|
|
|
+ },
|
|
|
+ init() {
|
|
|
+ // 设置播放容器的宽高并监听窗口大小变化
|
|
|
+ window.addEventListener('resize', () => {
|
|
|
+ setTimeout(()=>{
|
|
|
+ this.player.JS_Resize()
|
|
|
+ },50)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ reSize(){
|
|
|
+ this.player.JS_Resize()
|
|
|
+ },
|
|
|
+ /* getTraceId(curIndex){
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ this.player.JS_GetTraceId(curIndex).then((traceId) => {
|
|
|
+ console.log(this.player,traceId,"185");
|
|
|
+ resolve(traceId);
|
|
|
+ },(err) => {
|
|
|
+ console.log(err);
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }, */
|
|
|
+ createPlayer(option) {
|
|
|
+ this.player = new window.JSPlugin({
|
|
|
+ szId: 'player'+option.id,
|
|
|
+ szBasePath: '../../../../lib/js',
|
|
|
+ iMaxSplit: 4,
|
|
|
+ iCurrentSplit: option.split,
|
|
|
+ openDebug: false,
|
|
|
+ oStyle: {
|
|
|
+ border: '#343434',
|
|
|
+ borderSelect: '#FFCC00',
|
|
|
+ background: '#000'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 事件回调绑定
|
|
|
+ this.player.JS_SetWindowControlCallback({
|
|
|
+ windowEventSelect: async (iWndIndex)=> { //插件选中窗口回调
|
|
|
+ console.log(iWndIndex);
|
|
|
+ // let traceId = await this.getTraceId(iWndIndex);
|
|
|
+ // console.log(traceId,"traceId");
|
|
|
+ this.$emit("getCurrentIndex", iWndIndex);
|
|
|
+ },
|
|
|
+ pluginErrorHandler: (iWndIndex, iErrorCode, oError)=> { //插件错误回调
|
|
|
+ console.log('pluginError callback: ', iWndIndex, iErrorCode, oError);
|
|
|
+ if(iErrorCode == "0x12f910012" || iErrorCode == "0x01900050" || iErrorCode == "0x01b01307") {
|
|
|
+ this.$message.warning("窗口取流失败,详情根据错误码在运管后台进行查询.")
|
|
|
+ } else if(iErrorCode == "0x12f910011") {
|
|
|
+ this.$message.warning("流中断,电脑配置过低,程序卡主线程都可能导致流中断")
|
|
|
+ } else if(iErrorCode == "0x12f910010") {
|
|
|
+ this.$message.warnng("取流失败")
|
|
|
+ }
|
|
|
+ },
|
|
|
+ windowEventOver: (iWndIndex)=> { //鼠标移过回调
|
|
|
+ //console.log(iWndIndex);
|
|
|
+ },
|
|
|
+ windowEventOut: (iWndIndex)=> { //鼠标移出回调
|
|
|
+ //console.log(iWndIndex);
|
|
|
+ },
|
|
|
+ windowEventUp: (iWndIndex)=> { //鼠标mouseup事件回调
|
|
|
+ //console.log(iWndIndex);
|
|
|
+ },
|
|
|
+ windowFullCcreenChange: (bFull)=> { //全屏切换回调
|
|
|
+ console.log('fullScreen callback: ', bFull);
|
|
|
+ },
|
|
|
+ firstFrameDisplay: (iWndIndex, iWidth, iHeight)=> { //首帧显示回调
|
|
|
+ console.log('firstFrame loaded callback: ', iWndIndex, iWidth, iHeight);
|
|
|
+ },
|
|
|
+ performanceLack: ()=> { //性能不足回调
|
|
|
+ console.log('performanceLack callback: ');
|
|
|
+ },
|
|
|
+ StreamEnd: (index)=> { //回放结束回调,返回对应测窗口id
|
|
|
+ this.option.index=index;
|
|
|
+ this.play(this.option);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /* 分屏 */
|
|
|
+ arrangeWindow(splitNum) {
|
|
|
+ // let splitNum = this.splitNum 1
|
|
|
+ this.player.JS_ArrangeWindow(splitNum).then(
|
|
|
+ () => {
|
|
|
+ console.log(`arrangeWindow to ${splitNum}x${splitNum} success`)
|
|
|
+ },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ selectWindow(index){
|
|
|
+ this.player.JS_SelectWnd(index).then(
|
|
|
+ () => { },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 整体全屏 */
|
|
|
+ wholeFullScreen(boolean) {
|
|
|
+ this.init();
|
|
|
+ this.player.JS_FullScreenDisplay(boolean).then(
|
|
|
+ () => { console.log(`wholeFullScreen success`) },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 单窗口全屏 */
|
|
|
+ singleFullScreen(index) {
|
|
|
+ this.player.JS_FullScreenSingle(index).then(
|
|
|
+ () => {
|
|
|
+ console.info('JS_FullScreenSingle success');
|
|
|
+ // do you want...
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ console.info(err);
|
|
|
+ // do you want...
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 预览&对讲 */
|
|
|
+ realplay() {
|
|
|
+ let { player, mode, urls } = this,
|
|
|
+ index = player.currentWindowIndex,
|
|
|
+ playURL = urls.realplay;
|
|
|
+ player.JS_Play(playURL, { playURL, mode }, index).then(
|
|
|
+ () => { console.log('realplay success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 停止播放 */
|
|
|
+ stopPlay(index) {
|
|
|
+ console.log("当前选中要暂停的视频是:" + index );
|
|
|
+ this.player.JS_Stop(index).then(
|
|
|
+ () => { this.playback.rate = 0; console.log('stop realplay success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 开始对讲 */
|
|
|
+ talkStart(url) {
|
|
|
+ console.log(url);
|
|
|
+ // let url = this.urls.talk
|
|
|
+ this.player.JS_SetConnectTimeOut(0, 1000);
|
|
|
+ this.player.JS_StartTalk(url).then(
|
|
|
+ () => { console.log('talkStart success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 停止对讲 */
|
|
|
+ talkStop() {
|
|
|
+ this.player.JS_StopTalk().then(
|
|
|
+ () => { console.log('talkStop success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 停止所有播放 */
|
|
|
+ stopAllPlay() {
|
|
|
+ this.player.JS_StopRealPlayAll().then(
|
|
|
+ () => { this.playback.rate = 0; console.log('stopAllPlay success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 回放 */
|
|
|
+ playbackStart() {
|
|
|
+ let { player, mode, urls, playback } = this,
|
|
|
+ index = player.currentWindowIndex,
|
|
|
+ playURL = urls.playback,
|
|
|
+ { startTime, endTime } = playback
|
|
|
+ startTime += 'Z'
|
|
|
+ endTime += 'Z'
|
|
|
+ player.JS_Play(playURL, { playURL, mode }, index, startTime, endTime).then(
|
|
|
+ () => {
|
|
|
+ console.log('playbackStart success')
|
|
|
+ this.playback.rate = 1
|
|
|
+ },
|
|
|
+ e => { console.error(e) }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ /* 暂停回放 */
|
|
|
+ playbackPause() {
|
|
|
+ this.player.JS_Pause().then(
|
|
|
+ () => { console.log('playbackPause success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 恢复回放 */
|
|
|
+ playbackResume() {
|
|
|
+ this.player.JS_Resume().then(
|
|
|
+ () => { console.log('playbackResume success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 回放定位 */
|
|
|
+ seekTo() {
|
|
|
+ let { seekStart, endTime } = this.playback
|
|
|
+ seekStart += 'Z'
|
|
|
+ endTime += 'Z'
|
|
|
+ this.player.JS_Seek(this.player.currentWindowIndex, seekStart, endTime).then(
|
|
|
+ () => { console.log('seekTo success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 回放慢放 */
|
|
|
+ playbackSlow() {
|
|
|
+ this.player.JS_Slow().then(
|
|
|
+ rate => {
|
|
|
+ this.playback.rate = rate
|
|
|
+ },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 回放快放 */
|
|
|
+ playbackFast() {
|
|
|
+ this.player.JS_Fast().then(
|
|
|
+ rate => {
|
|
|
+ this.playback.rate = rate
|
|
|
+ },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 回放单帧进(高级模式功能) */
|
|
|
+ frameForward() {
|
|
|
+ this.player.JS_FrameForward(this.player.currentWindowIndex).then(
|
|
|
+ () => { this.playback.rate = 1; console.log('frameForward success') },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 开启声音 */
|
|
|
+ openSound(index) {
|
|
|
+ this.player.JS_OpenSound(index).then(
|
|
|
+ () => {
|
|
|
+ console.log('openSound success')
|
|
|
+ this.muted = false
|
|
|
+ },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 关闭声音 */
|
|
|
+ closeSound(index) {
|
|
|
+ this.player.JS_CloseSound(index).then(
|
|
|
+ () => {
|
|
|
+ console.log('closeSound success')
|
|
|
+ this.muted = true
|
|
|
+ },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 设置音量 */
|
|
|
+ setVolume(value) {
|
|
|
+ let player = this.player,
|
|
|
+ index = player.currentWindowIndex
|
|
|
+ this.player.JS_SetVolume(index, value).then(
|
|
|
+ () => {
|
|
|
+ console.log('setVolume success', value)
|
|
|
+ },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 抓图 */
|
|
|
+ capture(imageType) {
|
|
|
+ let player = this.player,
|
|
|
+ index = player.currentWindowIndex
|
|
|
+
|
|
|
+ player.JS_CapturePicture(index, 'img', imageType).then(
|
|
|
+ () => { console.log('capture success', imageType) },
|
|
|
+ e => { console.error(e) }
|
|
|
+ )
|
|
|
+ },
|
|
|
+ /* 录像 */
|
|
|
+ // recordStart(type) {
|
|
|
+ // const codeMap = { MP4: 5, PS: 2 }
|
|
|
+ // let player = this.player,
|
|
|
+ // index = player.currentWindowIndex,
|
|
|
+ // fileName = `${moment().format('YYYYMMDDHHmm')}.mp4`
|
|
|
+ // typeCode = codeMap[type]
|
|
|
+ //
|
|
|
+ // player.JS_StartSaveEx(index, fileName, typeCode).then(
|
|
|
+ // () => { console.log('record start ...') },
|
|
|
+ // e => { console.error(e) }
|
|
|
+ // )
|
|
|
+ // },
|
|
|
+ // /* 停止录像并保存文件 */
|
|
|
+ // recordStop() {
|
|
|
+ // let player = this.player
|
|
|
+ // index = player.currentWindowIndex
|
|
|
+ //
|
|
|
+ // player.JS_StopSave(index).then(
|
|
|
+ // () => { console.log('record stoped, saving ...') },
|
|
|
+ // e => { console.error(e) }
|
|
|
+ // )
|
|
|
+ // },
|
|
|
+ // /* 电子放大、智能信息 */
|
|
|
+ // enlarge() {
|
|
|
+ // let player = this.player,
|
|
|
+ // index = player.currentWindowIndex
|
|
|
+ //
|
|
|
+ // player.JS_EnableZoom(index).then(
|
|
|
+ // () => { console.log('enlarge start..., select range...') },
|
|
|
+ // e => { console.error(e) }
|
|
|
+ // )
|
|
|
+ // },
|
|
|
+ // enlargeClose() {
|
|
|
+ // let player = this.player,
|
|
|
+ // index = player.currentWindowIndex
|
|
|
+ //
|
|
|
+ // player.JS_DisableZoom(index).then(
|
|
|
+ // () => { console.log('enlargeClose success') },
|
|
|
+ // e => { console.error(e) }
|
|
|
+ // )
|
|
|
+ // },
|
|
|
+ // /* 开启/关闭智能信息展示(高级模式功能) */
|
|
|
+ // intellectTrigger(openFlag) {
|
|
|
+ // let player = this.player,
|
|
|
+ // index = player.currentWindowIndex
|
|
|
+ //
|
|
|
+ // let result = player.JS_RenderALLPrivateData(index,openFlag)
|
|
|
+ // console.log(`${openFlag ? 'open' : 'close'} intellect ${result === 1 ? 'success': 'failed'}`)
|
|
|
+ // },
|
|
|
+ // /* 获取音视频信息 */
|
|
|
+ // getvideoInfo() {
|
|
|
+ // let player = this.player,
|
|
|
+ // index = player.currentWindowIndex
|
|
|
+ //
|
|
|
+ // player.JS_GetVideoInfo(index).then(function (videoInfo) {
|
|
|
+ // console.log("videoInfo:", videoInfo);
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+ // /* 获取OSD时间 */
|
|
|
+ // getOSDTime() {
|
|
|
+ // let player = this.player,
|
|
|
+ // index = player.currentWindowIndex
|
|
|
+ //
|
|
|
+ // player.JS_GetOSDTime(index).then(function(time) {
|
|
|
+ // console.log("osdTime:", new Date(time));
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+ getCurrentIndex(){
|
|
|
+ return this.player.currentWindowIndex;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style>
|
|
|
+</style>
|