fix:提交视频文件mock数据

This commit is contained in:
wangzhongjie 2024-06-04 15:04:30 +08:00
parent e65c48f1eb
commit 8ec6377f77
7 changed files with 128 additions and 144 deletions

View File

@ -4,13 +4,13 @@
{ {
"name": "default", "name": "default",
"material": { "material": {
"certpath": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.cer", "certpath": "/Users/wangzhongjie/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.cer",
"storePassword": "0000001B0C5B52D8C8C6F415D4216EAD2848AA4A376B36FD72006E4072C15BA3D11E6E65C0D1FFA92A6D86", "storePassword": "0000001BC865153A35BD7DDD2950D70622A2081C58D17D2F5BBE67AE83F469B41A05EED0BB09AA66043089",
"keyAlias": "debugKey", "keyAlias": "debugKey",
"keyPassword": "0000001B8DCA3C8913C86858A0CDEAEB6BEE0DC29FCE9932930CA1FFE68FFF84341736AADF81F056CDD683", "keyPassword": "0000001BB839AC92D8CB8AF4765ADD271E687C74C82EC1D0ED2072093ADB1E831C3E99148406836748BCD7",
"profile": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p7b", "profile": "/Users/wangzhongjie/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p7b",
"signAlg": "SHA256withECDSA", "signAlg": "SHA256withECDSA",
"storeFile": "/Users/surenjun/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p12" "storeFile": "/Users/wangzhongjie/.ohos/config/openharmony/auto_ohos_default_subject-two_com.oh.dts.p12"
} }
} }
], ],

View File

@ -1,4 +1,5 @@
import {User} from "../pages/interfaces" import {User} from "../pages/interfaces"
// 候选人数据
export const CandidateData: Array<User> = [ export const CandidateData: Array<User> = [
{ {
sfzmhm: '342323199501470011', sfzmhm: '342323199501470011',

View File

@ -0,0 +1,35 @@
import { VideoConfig } from '../pages/interfaces'
// 视频配置默认数据
export const VideoConfigData: VideoConfig = {
videoNum: '1',
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',
spzd4: false,
spzd3: false,
spzd2: false,
spzd1: false,
zdyz: '5',
}

View File

@ -0,0 +1,3 @@
export * from "./CandidateData"
export * from "./VideoData"

View File

@ -13,7 +13,7 @@ import common from '@ohos.app.ability.common';
import { User, VideoConfig } from './interfaces'; import { User, VideoConfig } from './interfaces';
import WebRTCVoice from './webRTC/'; import WebRTCVoice from './webRTC/';
import promptAction from '@ohos.promptAction'; import promptAction from '@ohos.promptAction';
import { CandidateData, EmptyCandidateObject } from '../mock/CandidateData'; import { CandidateData, EmptyCandidateObject } from '../mock';
import { getSyncData } from '../common/service/initable'; import { getSyncData } from '../common/service/initable';
@Entry @Entry

View File

@ -1,10 +1,12 @@
import TopLogo from './compontents/topLogo' import TopLogo from './compontents/topLogo';
import FileUtil from '../common/utils/File' import FileUtil from '../common/utils/File';
import { VideoConfig } from './interfaces' import { VideoConfig } from './interfaces';
import common from '@ohos.app.ability.common'; import common from '@ohos.app.ability.common';
import promptAction from '@ohos.promptAction' import promptAction from '@ohos.promptAction';
import { startRecordVideo, endRecordVideo,takePhoto } from '../common/service/videoService' import { endRecordVideo, startRecordVideo, takePhoto } from '../common/service/videoService';
import { GlobalConfig } from '../config/index' import { GlobalConfig } from '../config/index';
import { VideoConfigData } from '../mock';
@Entry @Entry
@Component @Component
struct Index { struct Index {
@ -13,100 +15,37 @@ struct Index {
@State previewUri: Resource = $r('app.media.2_nor') @State previewUri: Resource = $r('app.media.2_nor')
@State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X @State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
@State inputFontSize: number = 10 //12 @State inputFontSize: number = 10 //12
@State rocordHandleObj:any = { @State rocordHandleObj: any = {
rocord_handle1:0, rocord_handle1: 0,
rocord_handle2:0, rocord_handle2: 0,
rocord_handle3:0, rocord_handle3: 0,
rocord_handle4:0 rocord_handle4: 0
} }
@State isAutoPlay: boolean = true @State isAutoPlay: boolean = true
@State showFlag: boolean = false @State showFlag: boolean = false
private vocObj = null;
@State showControls: boolean = false @State showControls: boolean = false
private fileUtil: FileUtil
@State @Watch('outClick') outFlag: boolean = false; @State @Watch('outClick') outFlag: boolean = false;
@State oldParam: VideoConfig = { @State oldParam: VideoConfig = VideoConfigData
videoNum:'1', @State param: VideoConfig = VideoConfigData
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',
spzd4:false,
spzd3:false,
spzd2:false,
spzd1:false,
zdyz:'5',
}
@State param: VideoConfig = {
videoNum:'1',
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',
spzd4:false,
spzd3:false,
spzd2:false,
spzd1:false,
zdyz:'5',
}
@State openFlag: boolean = true @State openFlag: boolean = true
@State lsArr: Array<any> = [ @State lsArr: Array<any> = [
{key:'第一路'}, { key: '第一路' },
{key:'第二路'}, { key: '第二路' },
{key:'第三路'}, { key: '第三路' },
{key:'第四路'}, { key: '第四路' },
] ]
private vocObj = null;
private fileUtil: FileUtil
private context = getContext(this) as common.UIAbilityContext; private context = getContext(this) as common.UIAbilityContext;
private controller1: VideoController = new VideoController() private controller1: VideoController = new VideoController()
private controller2: VideoController = new VideoController() private controller2: VideoController = new VideoController()
private controller3: VideoController = new VideoController() private controller3: VideoController = new VideoController()
private controller4: VideoController = new VideoController() private controller4: VideoController = new VideoController()
@State videoArr: Array<any> = [ @State videoArr: Array<any> = [
{td:'td1',controller:this.controller1,src:''}, { td: 'td1', controller: this.controller1, src: '' },
{td:'td2',controller:this.controller2,src:''}, { td: 'td2', controller: this.controller2, src: '' },
{td:'td3',controller:this.controller3,src:''}, { td: 'td3', controller: this.controller3, src: '' },
{td:'td4',controller:this.controller4,src:''}, { td: 'td4', controller: this.controller4, src: '' },
] ]
private inputController: TextInputController = new TextInputController() private inputController: TextInputController = new TextInputController()
@ -114,8 +53,8 @@ struct Index {
Column() { Column() {
TopLogo({ outFlag: $outFlag }) TopLogo({ outFlag: $outFlag })
Flex({ justifyContent: FlexAlign.SpaceBetween }) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
Flex({wrap:FlexWrap.Wrap,direction:FlexDirection.Row}) { Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row }) {
ForEach(this.videoArr,(item,index)=>{ ForEach(this.videoArr, (item, index) => {
Video({ Video({
src: this.openFlag ? `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param[item.td]}/main/av_stream` : '', src: this.openFlag ? `rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.param[item.td]}/main/av_stream` : '',
currentProgressRate: this.curRate, currentProgressRate: this.curRate,
@ -128,7 +67,7 @@ struct Index {
.controls(this.showControls) .controls(this.showControls)
.margin(10 * this.ratio) .margin(10 * this.ratio)
}) })
}.margin({ top: 37 * this.ratio, left: 30 * this.ratio }).width(600*this.ratio).height(600*this.ratio) }.margin({ top: 37 * this.ratio, left: 30 * this.ratio }).width(600 * this.ratio).height(600 * this.ratio)
Column() { Column() {
Image($r('app.media.shezhi')) Image($r('app.media.shezhi'))
@ -170,7 +109,7 @@ struct Index {
.margin({ bottom: 10 * this.ratio }) .margin({ bottom: 10 * this.ratio })
.onClick(() => { .onClick(() => {
for (let i = 1; i <= 4; i++) { for (let i = 1; i <= 4; i++) {
console.log('rocord_handle',i,JSON.stringify(this.rocordHandleObj)) console.log('rocord_handle', i, JSON.stringify(this.rocordHandleObj))
if (this.rocordHandleObj['rocord_handle'+i]) { if (this.rocordHandleObj['rocord_handle'+i]) {
endRecordVideo(this.rocordHandleObj['rocord_handle'+i]) endRecordVideo(this.rocordHandleObj['rocord_handle'+i])
this.rocordHandleObj['rocord_handle'+i] = 0 this.rocordHandleObj['rocord_handle'+i] = 0
@ -185,16 +124,16 @@ struct Index {
.width(215 * this.ratio) .width(215 * this.ratio)
.height(64 * this.ratio) .height(64 * this.ratio)
.onClick(async () => { .onClick(async () => {
const arr=['1','2','3','4'] const arr = ['1', '2', '3', '4']
if(!arr.includes(this.param.pztd)){ if (!arr.includes(this.param.pztd)) {
promptAction.showToast({ promptAction.showToast({
message: '请填写正确的拍照通道', message: '请填写正确的拍照通道',
duration: 3000 duration: 3000
}) })
return return
} }
try{ try {
await takePhoto(this.param,this.context,'pz/') await takePhoto(this.param, this.context, 'pz/')
promptAction.showToast({ promptAction.showToast({
message: '抓图完成', message: '抓图完成',
duration: 3000 duration: 3000
@ -203,8 +142,8 @@ struct Index {
// console.log('daihai err: ' + err) // console.log('daihai err: ' + err)
// }) // })
}catch (error){ } catch (error) {
console.log('daihai',error) console.log('daihai', error)
} }
}) })
@ -319,9 +258,10 @@ struct Index {
.width(34 * this.ratio) .width(34 * this.ratio)
.height(26 * this.ratio) .height(26 * this.ratio)
.fontSize(this.inputFontSize * this.ratio) .fontSize(this.inputFontSize * this.ratio)
.margin({ left: 10 * this.ratio, right: 15 * this.ratio }).onChange((value: string) => { .margin({ left: 10 * this.ratio, right: 15 * this.ratio })
this.param.zdyz = value .onChange((value: string) => {
}) this.param.zdyz = value
})
// Text('k').fontColor('#333333').fontSize(16 * this.ratio) // Text('k').fontColor('#333333').fontSize(16 * this.ratio)
// Text('链接类型').fontColor('#333333').fontSize(16 * this.ratio) // Text('链接类型').fontColor('#333333').fontSize(16 * this.ratio)
// TextInput({ text: this.param.ljlx, controller: this.inputController }) // TextInput({ text: this.param.ljlx, controller: this.inputController })
@ -339,6 +279,7 @@ struct Index {
Row() { Row() {
Row() { Row() {
}.width(70 * this.ratio) }.width(70 * this.ratio)
Text('IP地址') Text('IP地址')
.width(158 * this.ratio) .width(158 * this.ratio)
.fontSize(16 * this.ratio) .fontSize(16 * this.ratio)
@ -371,7 +312,7 @@ struct Index {
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
} }
ForEach(this.lsArr,(item,index)=>{ ForEach(this.lsArr, (item, index) => {
Row() { Row() {
Text(item.key) Text(item.key)
.width(70 * this.ratio) .width(70 * this.ratio)
@ -389,7 +330,7 @@ struct Index {
.onChange((value: string) => { .onChange((value: string) => {
this.param.ip = value this.param.ip = value
}) })
TextInput({ text: this.param['td'+(Number(index)+1)], controller: this.inputController }) TextInput({ text: this.param['td'+(Number(index) + 1)], controller: this.inputController })
.type(InputType.Normal) .type(InputType.Normal)
.borderRadius(2) .borderRadius(2)
.width(96 * this.ratio) .width(96 * this.ratio)
@ -398,7 +339,7 @@ struct Index {
.margin({ right: 10 * this.ratio }) .margin({ right: 10 * this.ratio })
.fontSize(this.inputFontSize * this.ratio) .fontSize(this.inputFontSize * this.ratio)
.onChange((value: string) => { .onChange((value: string) => {
this.param['td'+(Number(index)+1)] = value this.param['td'+(Number(index) + 1)] = value
}) })
TextInput({ text: this.param.userName, controller: this.inputController }) TextInput({ text: this.param.userName, controller: this.inputController })
.type(InputType.Normal) .type(InputType.Normal)
@ -498,7 +439,7 @@ struct Index {
.width(22 * this.ratio) .width(22 * this.ratio)
.height(22 * this.ratio) .height(22 * this.ratio)
.onChange((value: boolean) => { .onChange((value: boolean) => {
this.param.spzd1=value this.param.spzd1 = value
}) })
Text('一路').fontSize(16 * this.ratio).fontColor('#333333') Text('一路').fontSize(16 * this.ratio).fontColor('#333333')
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
@ -506,7 +447,7 @@ struct Index {
.width(22 * this.ratio) .width(22 * this.ratio)
.height(22 * this.ratio) .height(22 * this.ratio)
.onChange((value: boolean) => { .onChange((value: boolean) => {
this.param.spzd2=value this.param.spzd2 = value
}) })
Text('二路').fontSize(16 * this.ratio).fontColor('#333333') Text('二路').fontSize(16 * this.ratio).fontColor('#333333')
} }
@ -517,7 +458,7 @@ struct Index {
.width(22 * this.ratio) .width(22 * this.ratio)
.height(22 * this.ratio) .height(22 * this.ratio)
.onChange((value: boolean) => { .onChange((value: boolean) => {
this.param.spzd3=value this.param.spzd3 = value
}) })
Text('三路').fontSize(16 * this.ratio).fontColor('#333333') Text('三路').fontSize(16 * this.ratio).fontColor('#333333')
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' }) Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
@ -525,7 +466,7 @@ struct Index {
.width(22 * this.ratio) .width(22 * this.ratio)
.height(22 * this.ratio) .height(22 * this.ratio)
.onChange((value: boolean) => { .onChange((value: boolean) => {
this.param.spzd4=value this.param.spzd4 = value
}) })
Text('四路').fontSize(16 * this.ratio).fontColor('#333333') Text('四路').fontSize(16 * this.ratio).fontColor('#333333')
} }
@ -620,27 +561,31 @@ struct Index {
this.fileUtil = fileUtil this.fileUtil = fileUtil
this.getVideoConfig() this.getVideoConfig()
} }
async getfilehandleCode(td){
const record_handle = await startRecordVideo(this.param,td,this.context,'lp') async getfilehandleCode(td) {
this.rocordHandleObj['rocord_handle'+td]=record_handle const record_handle = await startRecordVideo(this.param, td, this.context, 'lp')
this.rocordHandleObj['rocord_handle'+td] = record_handle
} }
outClick() { outClick() {
this.openFlag = false this.openFlag = false
} }
sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay)) sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
async onPageShow() { async onPageShow() {
} }
async getVideoConfig() { async getVideoConfig() {
const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress+'/config/config3.txt'); const data = await this.fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt');
this.oldParam = JSON.parse(data) this.oldParam = JSON.parse(data)
this.param = JSON.parse(data) this.param = JSON.parse(data)
} }
async writeConfig() { async writeConfig() {
this.oldParam = JSON.parse(JSON.stringify(this.param)) this.oldParam = JSON.parse(JSON.stringify(this.param))
this.videoArr=JSON.parse(JSON.stringify(this.videoArr)) this.videoArr = JSON.parse(JSON.stringify(this.videoArr))
console.log('kkkk',JSON.stringify(this.param)) console.log('kkkk', JSON.stringify(this.param))
const folderPath = await this.fileUtil.initFolder(`/config`); const folderPath = await this.fileUtil.initFolder(`/config`);
this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.param), 'overWrite') this.fileUtil.addFile(`${folderPath}/config3.txt`, JSON.stringify(this.param), 'overWrite')
this.showFlag = false this.showFlag = false

View File

@ -75,12 +75,12 @@
{ {
"name": "ohos.permission.MEDIA_LOCATION" "name": "ohos.permission.MEDIA_LOCATION"
}, },
{ {
"name": "ohos.permission.WRITE_MEDIA" "name": "ohos.permission.WRITE_MEDIA"
}, },
{ {
"name": "ohos.permission.READ_MEDIA" "name": "ohos.permission.READ_MEDIA"
}, },
{ {
"name": "ohos.permission.WRITE_IMAGEVIDEO", "name": "ohos.permission.WRITE_IMAGEVIDEO",
"usedScene": { "usedScene": {
@ -99,26 +99,26 @@
"when": "always" "when": "always"
} }
}, },
// { // {
// "name": "ohos.permission.READ_MEDIA", // "name": "ohos.permission.READ_MEDIA",
// "reason": "$string:module_desc", // "reason": "$string:module_desc",
// "usedScene": { // "usedScene": {
// "abilities": [ // "abilities": [
// "MainAbility" // "MainAbility"
// ], // ],
// "when": "always" // "when": "always"
// } // }
// }, // },
// { // {
// "name": "ohos.permission.WRITE_MEDIA", // "name": "ohos.permission.WRITE_MEDIA",
// "reason": "$string:module_desc", // "reason": "$string:module_desc",
// "usedScene": { // "usedScene": {
// "abilities": [ // "abilities": [
// "MainAbility" // "MainAbility"
// ], // ],
// "when": "always" // "when": "always"
// } // }
// }, // },
{ {
"name": "ohos.permission.FILE_ACCESS_MANAGER", "name": "ohos.permission.FILE_ACCESS_MANAGER",
"reason": "$string:module_desc", "reason": "$string:module_desc",