import TopLogo from './compontents/topLogo' import FileUtil from '../common/utils/File' import { SourceType } from '@ohos.multimodalInput.touchEvent' import { VideoConfig } from './interfaces' import common from '@ohos.app.ability.common'; import router from '@ohos.router' import onvifclient from '@ohos.onvifclient'; import fs from '@ohos.file.fs' import prompt from '@ohos.prompt' import mediaLibrary from '@ohos.multimedia.mediaLibrary' // import { voiceService } from '../common/service/voiceService' @Entry @Component struct Index { @State ratio: number = 850 / 960 @State videoSrc: string = 'rtsp://admin:12345qwe@192.168.36.94:554/h264/ch3/main/av_stream' @State previewUri: Resource = $r('app.media.2_nor') @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X @State inputFontSize:number=10 //12 @State rocord_handle1: number = 0 @State rocord_handle2: number = 0 @State rocord_handle3: number = 0 @State rocord_handle4: number = 0 @State filehandle1: number = 0 @State filehandle2: number = 0 @State filehandle3: number = 0 @State filehandle4: number = 0 @State file_asset1: any = 0 @State file_asset2: any = 0 @State file_asset3: any = 0 @State file_asset4: any = 0 // file_handle1 @State isAutoPlay: boolean = true @State showFlag: boolean = false @State videoNum: string = '1' private vocObj = null; @State showControls: boolean = false private fileUtil: FileUtil @State @Watch('outClick') outFlag: boolean = false; @State oldParam: VideoConfig = { spls: '1', wz: '0,0', faceFlag: false, shuiying: true, pztd: '2', ljlx: '', ip: '192.168.36.94', port: '554', userName: 'admin', pwd: '12345qwe', td1: '1', td2: '2', td3: '3', td4: '4', videoRecord1: false, videoRecord2: true, videoRecord3: false, videoRecord4: false, text1: '', text2: '', text3: '', dolt: '', fontSize: '', rlls: '1' } @State param: VideoConfig = { spls: '1', wz: '0,0', faceFlag: false, shuiying: true, pztd: '2', ljlx: '', ip: '192.168.36.94', port: '554', userName: 'admin', pwd: '12345qwe', td1: '1', td2: '2', td3: '3', td4: '4', videoRecord1: false, videoRecord2: true, videoRecord3: false, videoRecord4: false, text1: '', text2: '', text3: '', dolt: '', fontSize: '', rlls: '1' } @State openFlag:boolean=true private context = getContext(this) as common.UIAbilityContext; private controller1: VideoController = new VideoController() private controller2: VideoController = new VideoController() private controller3: VideoController = new VideoController() private controller4: VideoController = new VideoController() private inputController: TextInputController = new TextInputController() // private mediaTest: mediaLibrary.MediaLibrary = mediaLibrary.getMediaLibrary(globalThis.abilityContext) build() { Column() { TopLogo({ outFlag: $outFlag }) Flex({ justifyContent: FlexAlign.SpaceBetween }) { Column() { Row() { if(this.openFlag){ Video({ src: `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td1}/main/av_stream`, // previewUri: this.previewUri, currentProgressRate: this.curRate, controller: this.controller1 }) .width(205 * this.ratio) .height(168 * this.ratio) .autoPlay(this.isAutoPlay) .controls(this.showControls) .margin(10 * this.ratio) Video({ src: `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td2}/main/av_stream`, // previewUri: this.previewUri, currentProgressRate: this.curRate, controller: this.controller1 }) .width(205 * this.ratio) .height(168 * this.ratio) .autoPlay(this.isAutoPlay) .controls(this.showControls) .margin(10 * this.ratio) } } Row() { if(this.openFlag){ Video({ src: `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td3}/main/av_stream`, // previewUri: this.previewUri, currentProgressRate: this.curRate, controller: this.controller3 }) .width(205 * this.ratio) .height(168 * this.ratio) .autoPlay(this.isAutoPlay) .controls(this.showControls) .margin(10 * this.ratio) Video({ src: `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.td4}/main/av_stream`, // previewUri: this.previewUri, currentProgressRate: this.curRate, controller: this.controller4 }) .width(205 * this.ratio) .height(168 * this.ratio) .autoPlay(this.isAutoPlay) .controls(this.showControls) .margin(10 * this.ratio) } } }.margin({ top: 37 * this.ratio, left: 30 * this.ratio }) Column() { Flex({ alignItems: ItemAlign.Center }) { Image($r('app.media.sz')) .width(28 * this.ratio) .height(28 * this.ratio) .margin({ right: 20 * this.ratio, left: 40 * this.ratio }) Text('设 置').fontColor('#fff').fontSize(24 * this.ratio).onClick(() => { }) } .width(215 * this.ratio) .height(64 * this.ratio) .backgroundImage($r('app.media.button_nor')) .backgroundImageSize({ width: '100%', height: '100%' }) .margin({ bottom: 10 * this.ratio }) .onClick(() => { this.showFlag = true }) Flex({ alignItems: ItemAlign.Center }) { Image($r('app.media.lx')) .width(28 * this.ratio) .height(28 * this.ratio) .margin({ right: 20 * this.ratio, left: 40 * this.ratio }) Text('录 像').fontColor('#fff').fontSize(24 * this.ratio).onClick(async () => { if (!this.param.videoRecord4 && !this.param.videoRecord3 && !this.param.videoRecord2 && !this.param.videoRecord1) { prompt.showToast({ message: '请选择录像通道', duration: 3000 }) return } if (this.rocord_handle1 || this.rocord_handle2 || this.rocord_handle3 || this.rocord_handle4) { return } if (this.param.videoRecord1) { // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch1/main/av_stream`; var mediaTest = mediaLibrary.getMediaLibrary(this.context); let mediaType = mediaLibrary.MediaType.VIDEO; let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; const num = Math.floor(Math.random() * 10000) const name = `movie_record${num}.mp4` const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); mediaTest.createAsset(mediaType, name, path, (error, asset) => { this.file_asset1 = asset; // 记录 ,关闭时用到 asset.open('rw', (error, fd) => { if (fd > 0) { var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name; var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd); this.filehandle1 = fd; // 记录 ,关闭时用到 this.rocord_handle1 = result3.dataInt; // 记录 ,关闭时用到 } else { console.error('baoyihu startRecordVideo File Open failed with error: ' + error); } }); }); } if (this.param.videoRecord2) { // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch2/main/av_stream`; var mediaTest = mediaLibrary.getMediaLibrary(this.context); let mediaType = mediaLibrary.MediaType.VIDEO; let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; const num = Math.floor(Math.random() * 10000) var videoName = `movie_record${num}.mp4` const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); const that = this mediaTest.createAsset(mediaType, videoName, path, (error, asset) => { this.file_asset2 = asset; // 记录 ,关闭时用到 asset.open('rw', (error, fd) => { if (fd > 0) { var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + videoName; that.filehandle2 = fd // 记录 ,关闭时用到 var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd); this.rocord_handle2 = result3.dataInt; // 记录 ,关闭时用到 } else { console.error(' startRecordVideo File Open failed with error: ' + error); } }); }); } if (this.param.videoRecord3) { // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch3/main/av_stream`; var mediaTest = mediaLibrary.getMediaLibrary(this.context); let mediaType = mediaLibrary.MediaType.VIDEO; let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; const num = Math.floor(Math.random() * 10000) const name = `movie_record${num}.mp4` const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); mediaTest.createAsset(mediaType, name, path, (error, asset) => { this.file_asset3 = asset; // 记录 ,关闭时用到 asset.open('rw', (error, fd) => { if (fd > 0) { var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name; var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd); this.filehandle3 = fd; // 记录 ,关闭时用到 this.rocord_handle3 = result3.dataInt; // 记录 ,关闭时用到 } else { console.error('baoyihu startRecordVideo File Open failed with error: ' + error); } }); }); } if (this.param.videoRecord4) { var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch4/main/av_stream`; var mediaTest = mediaLibrary.getMediaLibrary(this.context); let mediaType = mediaLibrary.MediaType.VIDEO; let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_VIDEO; const num = Math.floor(Math.random() * 10000) const name = `movie_record${num}.mp4` const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); mediaTest.createAsset(mediaType, name, path, (error, asset) => { this.file_asset4 = asset; // 记录 ,关闭时用到 asset.open('rw', (error, fd) => { if (fd > 0) { var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Videos/" + name; var result3 = onvifclient.startRecordVideo(video_uri, file_path, fd); this.filehandle4 = fd; // 记录 ,关闭时用到 this.rocord_handle4 = result3.dataInt; // 记录 ,关闭时用到 } else { console.error('baoyihu startRecordVideo File Open failed with error: ' + error); } }); }); } prompt.showToast({ message: '录像开始', duration: 3000 }) }) } .width(215 * this.ratio) .height(64 * this.ratio) .backgroundImage($r('app.media.button_nor')) .backgroundImageSize({ width: '100%', height: '100%' }) .margin({ bottom: 10 * this.ratio }) Flex({ alignItems: ItemAlign.Center }) { Image($r('app.media.tz')) .width(28 * this.ratio) .height(28 * this.ratio) .margin({ right: 20 * this.ratio, left: 40 * this.ratio }) Text('停 止').fontColor('#fff').fontSize(24 * this.ratio).onClick(() => { // if (!this.param.videoRecord4 && !this.param.videoRecord3 && !this.param.videoRecord2 && !this.param.videoRecord1) { // prompt.showToast({ // message: '请选择录像通道', // duration: 3000 // }) // return // } if (this.rocord_handle4) { var result4 = onvifclient.endRecordVideo(this.rocord_handle4); this.rocord_handle4 = 0 fs.closeSync(this.filehandle4) this.file_asset1.close(this.filehandle4); console.info(`baoyihu endRecordVideo result:` + result4.result + ` pictureFile:` + result4.dataString); } if (this.rocord_handle3) { var result3 = onvifclient.endRecordVideo(this.rocord_handle3); this.rocord_handle3 = 0 fs.closeSync(this.filehandle3); this.file_asset2.close(this.filehandle3); console.info(`baoyihu endRecordVideo result:` + result3.result + ` pictureFile:` + result3.dataString); } if (this.rocord_handle2) { console.log('tagtag',this.rocord_handle2,this.filehandle2) var result = onvifclient.endRecordVideo(this.rocord_handle2); this.rocord_handle2 = 0 fs.closeSync(this.filehandle2); this.file_asset2.close(this.filehandle2); console.info(`baoyihu endRecordVideo result:` + result.result + ` pictureFile:` + result.dataString); } if (this.rocord_handle1) { var result = onvifclient.endRecordVideo(this.filehandle1); this.rocord_handle1 = 0 fs.closeSync(this.filehandle1); this.file_asset2.close(this.filehandle1); console.info(`baoyihu endRecordVideo result:` + result.result + ` pictureFile:` + result.dataString); } this.rocord_handle1 = 0 this.rocord_handle2 = 0 this.rocord_handle3 = 0 this.rocord_handle4 = 0 prompt.showToast({ message: '录像结束', duration: 3000 }) }) } .width(215 * this.ratio) .height(64 * this.ratio) .backgroundImage($r('app.media.button_nor')) .backgroundImageSize({ width: '100%', height: '100%' }) .margin({ bottom: 10 * this.ratio }) Flex({ alignItems: ItemAlign.Center }) { Image($r('app.media.zt')) .width(28 * this.ratio) .height(28 * this.ratio) .margin({ right: 20 * this.ratio, left: 40 * this.ratio }) Text('抓 图').fontColor('#fff').fontSize(24 * this.ratio).onClick(async () => { if (this.param.pztd != '1' && this.param.pztd != '2' && this.param.pztd != '3' && this.param.pztd != '4') { prompt.showToast({ message: '请填写正确的拍照通道', duration: 3000 }) return } // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } var video_uri = `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param.pztd}/main/av_stream`; // var file_dir = "/data/service/el1/public/netmanager/ethernet/"; // var result3 = onvifclient.getVideoSnapshot(loginInfo1, video_uri, file_dir); // console.info(`baoyihu endRecordVideo result:` + result3.result + ` pictureFile:` + result3.dataString); // const randomNum=Math.floor(Math.random()*100) // var file_path = "/data/storage/el2/base/haps/entry/files/picture_record"+randomNum+".jpg"; // let writeFile = fs.openSync(file_path, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE) // var fileid = writeFile.fd; // var result3 = onvifclient.getVideoSnapshot(video_uri,file_path); // fs.closeSync(fileid); var mediaTest = mediaLibrary.getMediaLibrary(this.context); let mediaType = mediaLibrary.MediaType.IMAGE; let DIR_DOCUMENTS = mediaLibrary.DirectoryType.DIR_IMAGE; const path = await mediaTest.getPublicDirectory(DIR_DOCUMENTS); const randomNum = Math.floor(Math.random() * 100) mediaTest.createAsset(mediaType, "picture_record" + randomNum + ".jpg", path, (error, asset) => { asset.open('rw', (error, fd) => { if (fd > 0) { var file_path = "/mnt/hmdfs/100/account/device_view/local/files/Pictures/picture_record" + randomNum + ".jpg" var result3 = onvifclient.getVideoSnapshot(video_uri, file_path, fd); fs.closeSync(fd); asset.close(fd); prompt.showToast({ message: '抓图完成', duration: 3000 }) } else { console.error('baoyihu getVideoSnapshot File Open failed with error: ' + error); } }); }); // let mediaType = mediaLibrary.MediaType.FILE; // let DIR_IMAGE = mediaLibrary.DirectoryType.DIR_IMAGE; // const path = await this.mediaTest.getPublicDirectory(DIR_IMAGE); // const asset = await this.mediaTest.createAsset(mediaType, 'picture_record'+randomNum+'.jpg', path); // console.info(`baoyihu endRecordVideo result:` + result3.result + ` pictureFile:` + result3.dataString); }) } .width(215 * this.ratio) .height(64 * this.ratio) .backgroundImage($r('app.media.button_nor')) .backgroundImageSize({ width: '100%', height: '100%' }) .margin({ bottom: 10 * this.ratio }) }.margin({ right: 38 * this.ratio, top: 110 * this.ratio }) }.backgroundColor('#1A1A1A') Column() { Text('提示信息:') .fontSize(18 * this.ratio) .fontColor('#fff') .margin({ left: 29 * this.ratio, top: 13 * this.ratio }) .align(Alignment.Start) .width('100%') }.width('100%').height(70 * this.ratio).backgroundColor('#333230').position({ x: 0, y: 470 * this.ratio }) if (this.showFlag) { Column() { Flex({ justifyContent: FlexAlign.SpaceBetween }) { Text('视频参数设置') .width('100%') .align(Alignment.Start) .fontSize(24 * this.ratio) .fontColor('#333333') .margin({ left: 20 * this.ratio, top: 22 * this.ratio }) Row() { Image($r('app.media.fh')).width(117 * this.ratio).height(50 * this.ratio).onClick(() => { // this.oldParam = JSON.parse(JSON.stringify(this.param)) this.param=JSON.parse(JSON.stringify(this.oldParam)) this.showFlag = false }) Image($r('app.media.bc')) .width(117 * this.ratio) .height(50 * this.ratio) .margin({ left: 15 * this.ratio }) .onClick(() => { console.log('111111') this.writeConfig() }) }.margin({ right: 135 * this.ratio, top: 10 * this.ratio }) } Column() { Row() { Text('视频路数').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 13 * this.ratio }) TextInput({ text: this.videoNum, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(34 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ left: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value) => { this.param.spls = value }) Column() { Image($r('app.media.shang')).width(15 * this.ratio).height(15 * this.ratio).onClick(() => { this.videoNum = (parseInt(this.videoNum) + 1).toString() }) Image($r('app.media.xia')).width(15 * this.ratio).height(15 * this.ratio).onClick(() => { this.videoNum = (parseInt(this.videoNum) - 1).toString() }) }.margin({ left: 5 * this.ratio, right: 10 * this.ratio }) Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) .select(this.param.faceFlag) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { this.param.faceFlag = value console.info('Checkbox1 change is' + value) }) Text('启用过程人脸比对').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: this.param.rlls, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(34 * this.ratio) .fontSize(this.inputFontSize*this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ left: 10 * this.ratio, right: 15 * this.ratio }) .onChange((value) => { this.param.rlls = value }) Text('拍照通道').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: this.param.pztd, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .padding({ top:0,bottom:0 }) .width(34 * this.ratio) .height(26 * this.ratio) .fontSize(this.inputFontSize*this.ratio) .margin({ left: 10 * this.ratio, right: 15 * this.ratio }) .onChange((value: string) => { this.param.pztd = value }) Text('设备类型').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: '海康', controller: this.inputController }) .borderRadius(0) .padding({ bottom:0,top:0 }) .width(67 * this.ratio) .height(26 * this.ratio) .fontSize(this.inputFontSize*this.ratio) .margin({ left: 10 * this.ratio, right: 15 * this.ratio }) // Select([{ value: '一路',}, // { value: '二路', }, // { value: '三路',}, // { value: '四路' }]).width(67 * this.ratio).borderRadius(0) .height(26 * this.ratio).selected(2).margin({ left: 10 * this.ratio,right:15*this.ratio }) Text('信号大小').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: this.param.spls, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .padding({ top:0,bottom:0 }) .width(34 * this.ratio) .height(26 * this.ratio) .fontSize(this.inputFontSize*this.ratio) .margin({ left: 10 * this.ratio, right: 15 * this.ratio }) Text('k').fontColor('#333333').fontSize(16 * this.ratio) Text('链接类型').fontColor('#333333').fontSize(16 * this.ratio) TextInput({ text: this.param.ljlx, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .padding({ top:0,bottom:0 }) .width(34 * this.ratio) .height(26 * this.ratio) .fontSize(this.inputFontSize*this.ratio) .margin({ left: 10 * this.ratio, right: 5 * this.ratio }) }.width('100%').align(Alignment.Start).backgroundColor('#E5E3DF') Row() { Column() { Row() { Row() { }.width(70 * this.ratio) Text('IP地址') .width(158 * this.ratio) .fontSize(16 * this.ratio) .fontColor('#666666') .margin({ right: 10 * this.ratio }) .textAlign(TextAlign.Center) Text('通道号') .width(96 * this.ratio) .fontSize(16 * this.ratio) .fontColor('#666666') .margin({ right: 10 * this.ratio }) .textAlign(TextAlign.Center) Text('用户名') .width(120 * this.ratio) .fontSize(16 * this.ratio) .fontColor('#666666') .margin({ right: 10 * this.ratio }) .textAlign(TextAlign.Center) Text('密码') .width(120 * this.ratio) .fontSize(16 * this.ratio) .fontColor('#666666') .margin({ right: 10 * this.ratio }) .textAlign(TextAlign.Center) Text('端口号') .width(60 * this.ratio) .fontSize(16 * this.ratio) .fontColor('#666666') .margin({ right: 10 * this.ratio }) .textAlign(TextAlign.Center) } Row() { Text('第一路') .width(70 * this.ratio) .fontColor('#333333') .fontSize(16 * this.ratio) .textAlign(TextAlign.Center) TextInput({ text: this.param.ip, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(158 * this.ratio) .height(26 * this.ratio) .fontSize(this.inputFontSize*this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .onChange((value: string) => { this.param.ip = value }) TextInput({ text: this.param.td1, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(96 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.td1 = value }) TextInput({ text: this.param.userName, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(120 * this.ratio) .height(26 * this.ratio) .margin({ right: 10 * this.ratio }) .padding({ top:0,bottom:0 }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.userName = value }) TextInput({ text: this.param.pwd, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(120 * this.ratio) .height(26 * this.ratio) .fontSize(this.inputFontSize*this.ratio) .margin({ right: 10 * this.ratio }) .padding({ top:0,bottom:0 }) .onChange((value: string) => { this.param.pwd = value }) TextInput({ text: this.param.port, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(60 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.port = value }) }.margin({ top: 10 * this.ratio }) Row() { Text('第二路') .width(70 * this.ratio) .fontColor('#333333') .fontSize(16 * this.ratio) .textAlign(TextAlign.Center) TextInput({ text: this.param.ip, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .padding({ top:0,bottom:0 }) .width(158 * this.ratio) .height(26 * this.ratio) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.ip = value }) TextInput({ text: this.param.td2, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(96 * this.ratio) .height(26 * this.ratio) .margin({ right: 10 * this.ratio }) .padding({ top:0,bottom:0 }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.td2 = value }) TextInput({ text: this.param.userName, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(120 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.userName = value }) TextInput({ text: this.param.pwd, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .padding({ top:0,bottom:0 }) .width(120 * this.ratio) .height(26 * this.ratio) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.pwd = value }) TextInput({ text: this.param.port, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(60 * this.ratio) .padding({ top:0,bottom:0 }) .height(26 * this.ratio) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.port = value }) }.margin({ top: 10 * this.ratio }) Row() { Text('第三路') .width(70 * this.ratio) .fontColor('#333333') .fontSize(16 * this.ratio) .textAlign(TextAlign.Center) TextInput({ text: this.param.ip, controller: this.inputController }) .type(InputType.Normal) .fontSize(this.inputFontSize*this.ratio) .borderRadius(2) .width(158 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .onChange((value: string) => { this.param.ip = value }) TextInput({ text: this.param.td3, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(96 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.td3 = value }) TextInput({ text: this.param.userName, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(120 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.userName = value }) TextInput({ text: this.param.pwd, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(120 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.pwd = value }) TextInput({ text: this.param.port, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(60 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .fontSize(this.inputFontSize*this.ratio) .margin({ right: 10 * this.ratio }) .onChange((value: string) => { this.param.port = value }) }.margin({ top: 10 * this.ratio }) Row() { Text('第四路') .width(70 * this.ratio) .fontColor('#333333') .fontSize(16 * this.ratio) .textAlign(TextAlign.Center) TextInput({ text: this.param.ip, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(158 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .fontSize(this.inputFontSize*this.ratio) .margin({ right: 10 * this.ratio }) .onChange((value: string) => { this.param.ip = value }) TextInput({ text: this.param.td4, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(96 * this.ratio) .height(26 * this.ratio) .fontSize(this.inputFontSize*this.ratio) .margin({ right: 10 * this.ratio }) .padding({ top:0,bottom:0 }) .onChange((value: string) => { this.param.td4 = value }) TextInput({ text: this.param.userName, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(120 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.userName = value }) TextInput({ text: this.param.pwd, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(120 * this.ratio) .height(26 * this.ratio) .margin({ right: 10 * this.ratio }) .padding({ top:0,bottom:0 }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.param.pwd = value }) TextInput({ text: this.param.port, controller: this.inputController }) .type(InputType.Normal) .borderRadius(2) .width(60 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ right: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .onChange((value: string) => { this.oldParam.port = value }) }.margin({ top: 10 * this.ratio }) }.width(672 * this.ratio).height(174 * this.ratio).backgroundColor('#EDEBE8') Column() { Row() { // Text('录像方式').fontSize(16*this.ratio).fontColor('#333333') // TextInput({ text: this.param.spls, controller: this.inputController }) // .type(InputType.Number) // .borderRadius(0) // .width(160 * this.ratio) // .height(26 * this.ratio) // .margin({ left: 10 * this.ratio }) // Select([{ value: '一路',}, // { value: '二路', }, // { value: '三路',}, // { value: '四路' }]).width(160 * this.ratio).borderRadius(0) .height(26 * this.ratio).selected(2).margin({ left: 10 * this.ratio,right:15*this.ratio }) } Row() { Text('录像范围').fontSize(16 * this.ratio).fontColor('#333333').margin({ top: 10 * this.ratio }) Row() { Column() { Row() { Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) .select(this.param.videoRecord1) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { this.param.videoRecord1 = value console.info('Checkbox1 change is' + value) }) Text('一路').fontSize(16 * this.ratio).fontColor('#333333') Checkbox({ name: 'checkbox2', group: 'checkboxGroup' }) .select(this.param.videoRecord2) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { this.param.videoRecord2 = value console.info('Checkbox1 change is' + value) }) Text('二路').fontSize(16 * this.ratio).fontColor('#333333') } Row() { Checkbox({ name: 'checkbox3', group: 'checkboxGroup' }) .select(this.param.videoRecord3) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { this.param.videoRecord3 = value console.info('Checkbox1 change is' + value) }) Text('三路').fontSize(16 * this.ratio).fontColor('#333333') Checkbox({ name: 'checkbox4', group: 'checkboxGroup' }) .select(this.param.videoRecord4) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { this.param.videoRecord4 = value console.info('Checkbox1 change is' + value) }) Text('四路').fontSize(16 * this.ratio).fontColor('#333333') } } } }.alignItems(VerticalAlign.Top).justifyContent(FlexAlign.Start) Row() { Text('视频遮挡').fontSize(16 * this.ratio).fontColor('#333333').margin({ top: 10 * this.ratio }) Row() { Column() { Row() { Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) .select(true) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { console.info('Checkbox1 change is' + value) }) Text('一路').fontSize(16 * this.ratio).fontColor('#333333') Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) .select(true) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { console.info('Checkbox1 change is' + value) }) Text('二路').fontSize(16 * this.ratio).fontColor('#333333') } Row() { Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) .select(true) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { console.info('Checkbox1 change is' + value) }) Text('三路').fontSize(16 * this.ratio).fontColor('#333333') Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) .select(true) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { console.info('Checkbox1 change is' + value) }) Text('四路').fontSize(16 * this.ratio).fontColor('#333333') } } } }.alignItems(VerticalAlign.Top).justifyContent(FlexAlign.Start) }.width(267 * this.ratio).height(174 * this.ratio).margin({ left: 7 * this.ratio, top: 10 * this.ratio }) }.width('100%') Row() { Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) .select(this.param.shuiying) .width(22 * this.ratio) .height(22 * this.ratio) .onChange((value: boolean) => { console.info('Checkbox1 change is' + value) }) Text('照片叠加文字').fontColor('#333333').fontSize(16 * this.ratio) Text('位置').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 24 * this.ratio }) TextInput({ text: this.param.wz, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(79 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .fontSize(this.inputFontSize*this.ratio) .margin({ left: 10 * this.ratio }) Text('叠加内容').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 24 * this.ratio }) TextInput({ text: this.param.text1, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(79 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ left: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) Text('+').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 5 * this.ratio }) TextInput({ text: this.param.text2, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(79 * this.ratio) .height(26 * this.ratio) .padding({ top:0,bottom:0 }) .margin({ left: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) Text('+').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 5 * this.ratio }) TextInput({ text: this.param.text3, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(79 * this.ratio) .padding({ top:0,bottom:0 }) .height(26 * this.ratio) .margin({ left: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) Text('分隔符').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 24 * this.ratio }) TextInput({ text: this.param.dolt, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(67 * this.ratio) .height(26 * this.ratio) .margin({ left: 10 * this.ratio }) .padding({ top:0,bottom:0 }) .fontSize(this.inputFontSize*this.ratio) Text('文字大小').fontColor('#333333').fontSize(16 * this.ratio).margin({ left: 24 * this.ratio }) TextInput({ text: this.param.fontSize, controller: this.inputController }) .type(InputType.Normal) .borderRadius(0) .width(34 * this.ratio) .height(26 * this.ratio) .margin({ left: 10 * this.ratio }) .fontSize(this.inputFontSize*this.ratio) .padding({ top:0,bottom:0 }) }.width('100%').align(Alignment.Start).backgroundColor('#E5E3DF') // Flex(){ // Text('本考车对应视频合成信息处理系统IP、本地响应端口') // .fontSize(16*this.ratio).fontColor('#333333').width(500*this.ratio).margin({left:5*this.ratio}) // TextInput({ text: this.param.spls, controller: this.inputController }) // .type(InputType.Number) // .borderRadius(0) // .width(200 * this.ratio) // .height(26 * this.ratio) // .margin({ left: 10 * this.ratio }) // TextInput({ text: this.param.spls, controller: this.inputController }) // .type(InputType.Number) // .borderRadius(0) // .width(58 * this.ratio) // .height(26 * this.ratio) // .margin({ left: 10 * this.ratio }) // Text('填错或不填将可能导致录像丢失') // .fontSize(16*this.ratio).fontColor('#FF7F66').width(400*this.ratio).margin({left:20*this.ratio}) // }.align(Alignment.Start).margin({top:10*this.ratio}) // Flex(){ // Text('本考车对应视频合成服务器IP、端口') // .fontSize(16*this.ratio).fontColor('#333333').width(500*this.ratio).margin({left:5*this.ratio}) // TextInput({ text: this.param.spls, controller: this.inputController }) // .type(InputType.Number) // .borderRadius(0) // .width(200 * this.ratio) // .height(26 * this.ratio) // .margin({ left: 10 * this.ratio }) // TextInput({ text: this.param.spls, controller: this.inputController }) // .type(InputType.Number) // .borderRadius(0) // .width(58 * this.ratio) // .height(26 * this.ratio) // .margin({ left: 10 * this.ratio }) // Text('填错将不能开始考试') // .fontSize(16*this.ratio).fontColor('#FF7F66').width(400*this.ratio).margin({left:20*this.ratio}) // }.align(Alignment.Start).margin({top:10*this.ratio}) }.width(946 * this.ratio).height(336 * this.ratio).backgroundColor('#E5E3DF').margin({ top: 13 * this.ratio }) } .width('100%') .height(395 * this.ratio) .backgroundColor('#CCC4B8') .position({ x: 0, y: 146 * this.ratio }) .border({ radius: { topLeft: 24 * this.ratio, topRight: 24 * this.ratio } }) } }.backgroundColor('#1A1A1A').width('100%').height('100%') } aboutToAppear() { this.openFlag=true const fileUtil = new FileUtil(this.context) this.fileUtil = fileUtil //获取参数配置 // this.vocObj = new voiceService(async (status, val) => { // if (status == 'idle') { // // } // }); this.getVideoConfig() // return // // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } // // var // loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' } // // // var result = onvifclient.getAllOSD(loginInfo); // // var create_str = "{\"VideoSourceToken\": \"VideoSourceToken\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\": 0.15454499125480652,\"Position_Y\": -0.477780294418335,\"TextType\": \"Plain\",\"FontSize\": 32,\"PlainText\": \"Camera 99\"}" // var create_str = { // "ConfigurationToken": "VideoSourceToken", // "Type": "Text", // "PositionType": "Custom", // "Position_X": 0.15454499125480652, // "Position_Y": -0.477780294418335, // "TextType": "Plain", // "FontSize": 32, // "PlainText": "Camera 99" // } // var result = onvifclient.createOSD(loginInfo, JSON.stringify(create_str)); // console.info(`baoyihu createOSD end result:` + result.result + ` dataString:` + result.dataString); // console.info( `baoyihu getAllOSD end result:`+result.result+ ` dataString:`+result.dataString ); // var set_str = {"ConfigurationToken": "VideoSourceToken","OSDToken": "OsdToken_100","Type": "Text","PositionType": "Custom","Position_X": 0.45454499125480652,"Position_Y": -0.077780294418335,"TextType": "Plain","FontSize": 32,"PlainText": "baoyihu shige dahaoren"} // console.info('Index onPageShow'); } outClick() { this.openFlag=false } async init() { } async onPageShow() { } async getVideoConfig() { const data = await this.fileUtil.readFile('/mnt/hmdfs/100/account/device_view/localfiles/files/config/config3.txt'); this.oldParam = JSON.parse(data) this.param = JSON.parse(data) } async writeConfig() { this.oldParam = JSON.parse(JSON.stringify(this.param)) const param = { videoNum: this.videoNum, //视频路数 faceFlag: this.param.faceFlag, //启用人脸比对 pztd: this.param.pztd, //拍照通道 ljlx: this.param.ljlx, ip: this.param.ip, port: this.param.port, userName: this.param.userName, pwd: this.param.pwd, td1: this.param.td1, td2: this.param.td2, td3: this.param.td3, td4: this.param.td4, wz: this.param.wz, text3: this.param.text3, text2: this.param.text2, text1: this.param.text1, dolt: this.param.dolt, shuiying: this.param.shuiying, fontSize: this.param.fontSize, rlls: this.param.rlls, videoRecord1:this.param.videoRecord1, videoRecord2:this.param.videoRecord2, videoRecord3:this.param.videoRecord3, videoRecord4:this.param.videoRecord4 } const folderPath = await this.fileUtil.initFolder(`/config`); this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(param), 'overWrite') this.showFlag = false // if(this.param.shuiying) { // //查询水印 // var loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' } // var result = onvifclient.getAllOSD(loginInfo); // console.info( `baoyihu getAllOSD end result:`+result.result+ ` dataString:`+result.dataString ); // let text='' // if(this.param.dolt!=''){ // if(this.param.text1){ // text+=this.param.text1 // } // if(this.param.text2){ // text+=this.param.dolt+this.param.text2 // } // if(this.param.text3){ // text+=this.param.dolt+this.param.text3 // } // } // else{ // if(this.param.text1){ // text+=this.param.text1 // } // if(this.param.text2){ // text+=','+this.param.text2 // } // if(this.param.text3){ // text+=','+this.param.text3 // } // } // let x='0'; // let y='0' // if(this.param.wz){ // x=this.param.wz.split(',')[0] // y=this.param.wz.split(',')[0] // } // if(result.result){ // //存在 // var set_str = `{\"ConfigurationToken\": \"VideoSourceToken\",\"OSDToken\": \"OsdToken_100\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\":${x},\"Position_Y\": ${y},\"TextType\": \"Plain\",\"FontSize\": ${this.param.fontSize},\"PlainText\": \"${text}\"}` // var result = onvifclient.setOSD(loginInfo,set_str); // }else{ // var create_str = `{\"ConfigurationToken\": \"VideoSourceToken\",\"Type\": \"Text\",\"PositionType\": \"Custom\",\"Position_X\": 0.15454499125480652,\"Position_Y\": -0.477780294418335,\"TextType\": \"Plain\",\"FontSize\": 32,\"PlainText\": \"Camera 99\"}` // var result = onvifclient.createOSD(loginInfo,create_str); // console.info( `baoyihu createOSD end result:`+result.result+ ` dataString:`+result.dataString ); // } // }else{ // // var loginInfo1 = { host: `http://${this.param.ip}:80`, user: "administrator", pass: this.param.pwd } // // var loginInfo = { host: `http://192.168.36.94:80`, user: "administor", pass: '12345qwe' } // var result1 = onvifclient.deleteOSD(loginInfo,"OsdToken_102"); // console.info( `baoyihu deleteOSD end result:`+result1.result+ ` dataString:`+result1.dataString ); // } // const isEdit = this.fileUtilObj.editFile(`${folderPath}/videoConfig.txt`,param.toString()) } }