fix: VideoConfig.ets
This commit is contained in:
parent
438f3f3438
commit
6315aadc47
@ -70,3 +70,6 @@ export interface VideoConfig {
|
||||
zdyz: string,
|
||||
}
|
||||
|
||||
export interface CommonType {
|
||||
key: string;
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
export interface RecordHandleType {
|
||||
rocord_handle1: number;
|
||||
rocord_handle2: number;
|
||||
rocord_handle3: number;
|
||||
rocord_handle4: number;
|
||||
}
|
||||
|
||||
export interface VideoItemType {
|
||||
td: string;
|
||||
controller: VideoController;
|
||||
src: string;
|
||||
}
|
||||
@ -6,4 +6,6 @@ export * from "./Common"
|
||||
|
||||
export * from "./Judge"
|
||||
|
||||
export * from "./Register"
|
||||
export * from "./Register"
|
||||
|
||||
export * from "./VideoConfig"
|
||||
@ -5,7 +5,7 @@ import promptAction from '@ohos.promptAction';
|
||||
import { endRecordVideo, startRecordVideo, takePhoto } from '../service/videoService';
|
||||
import { GlobalConfig } from '../config/index';
|
||||
import { VideoConfigData } from '../mock';
|
||||
import { VideoConfig } from '../model';
|
||||
import { CommonType, RecordHandleType, VideoConfig, VideoItemType } from '../model';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -15,7 +15,7 @@ struct Index {
|
||||
@State previewUri: Resource = $r('app.media.2_nor')
|
||||
@State curRate: PlaybackSpeed = PlaybackSpeed.Speed_Forward_1_00_X
|
||||
@State inputFontSize: number = 10 //12
|
||||
@State rocordHandleObj: any = {
|
||||
@State rocordHandleObj: RecordHandleType = {
|
||||
rocord_handle1: 0,
|
||||
rocord_handle2: 0,
|
||||
rocord_handle3: 0,
|
||||
@ -30,7 +30,7 @@ struct Index {
|
||||
@State oldParam: VideoConfig = VideoConfigData
|
||||
@State param: VideoConfig = VideoConfigData
|
||||
@State openFlag: boolean = true
|
||||
@State lsArr: Array<any> = [
|
||||
@State lsArr: Array<CommonType> = [
|
||||
{ key: '第一路' },
|
||||
{ key: '第二路' },
|
||||
{ key: '第三路' },
|
||||
@ -42,7 +42,7 @@ struct Index {
|
||||
private controller2: VideoController = new VideoController()
|
||||
private controller3: VideoController = new VideoController()
|
||||
private controller4: VideoController = new VideoController()
|
||||
@State videoArr: Array<any> = [
|
||||
@State videoArr: Array<VideoItemType> = [
|
||||
{ td: 'td1', controller: this.controller1, src: '' },
|
||||
{ td: 'td2', controller: this.controller2, src: '' },
|
||||
{ td: 'td3', controller: this.controller3, src: '' },
|
||||
@ -55,10 +55,10 @@ struct Index {
|
||||
TopLogo({ outFlag: $outFlag })
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween }) {
|
||||
Flex({ wrap: FlexWrap.Wrap, direction: FlexDirection.Row }) {
|
||||
ForEach(this.videoArr, (item, index) => {
|
||||
ForEach(this.videoArr, (item: VideoItemType, index) => {
|
||||
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` :
|
||||
`rtsp://${this.param.userName}:${this.param.pwd}@${this.param.ip}:${this.param.port}/h264/ch${this.getTdValueByTd(item.td)}/main/av_stream` :
|
||||
'',
|
||||
currentProgressRate: this.curRate,
|
||||
controller: item.controller
|
||||
@ -101,9 +101,14 @@ struct Index {
|
||||
return
|
||||
}
|
||||
this.videoStartFlag = true
|
||||
// for (let i = 1; i <= 4; i++) {
|
||||
// if (this.param['videoRecord'+i]) {
|
||||
// await this.getFileHandleCode(i)
|
||||
// }
|
||||
// }
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
if (this.param['videoRecord'+i]) {
|
||||
await this.getfilehandleCode(i)
|
||||
if (this.getVideoRecordValue(i)) {
|
||||
await this.getFileHandleCode(i);
|
||||
}
|
||||
}
|
||||
this.videoStartFlag = false
|
||||
@ -118,11 +123,17 @@ struct Index {
|
||||
|
||||
.margin({ bottom: 10 * this.ratio })
|
||||
.onClick(() => {
|
||||
// for (let i = 1; i <= 4; i++) {
|
||||
// if (this.rocordHandleObj['rocord_handle'+i]) {
|
||||
// endRecordVideo(this.rocordHandleObj['rocord_handle'+i])
|
||||
// this.rocordHandleObj['rocord_handle'+i] = 0
|
||||
// }
|
||||
// }
|
||||
for (let i = 1; i <= 4; i++) {
|
||||
console.log('rocord_handle', i, JSON.stringify(this.rocordHandleObj))
|
||||
if (this.rocordHandleObj['rocord_handle'+i]) {
|
||||
endRecordVideo(this.rocordHandleObj['rocord_handle'+i])
|
||||
this.rocordHandleObj['rocord_handle'+i] = 0
|
||||
const handle: ESObject = this.getRecordHandle(i);
|
||||
if (handle) {
|
||||
endRecordVideo(handle);
|
||||
this.setRecordHandle(i, 0);
|
||||
}
|
||||
}
|
||||
promptAction.showToast({
|
||||
@ -327,7 +338,7 @@ struct Index {
|
||||
.textAlign(TextAlign.Center)
|
||||
}
|
||||
|
||||
ForEach(this.lsArr, (item, index) => {
|
||||
ForEach(this.lsArr, (item: CommonType, index) => {
|
||||
Row() {
|
||||
Text(item.key)
|
||||
.width(70 * this.ratio)
|
||||
@ -345,7 +356,7 @@ struct Index {
|
||||
.onChange((value: string) => {
|
||||
this.param.ip = value
|
||||
})
|
||||
TextInput({ text: this.param['td'+(Number(index) + 1)], controller: this.inputController })
|
||||
TextInput({ text: this.getTdValueByIndex((Number(index) + 1)), controller: this.inputController })
|
||||
.type(InputType.Normal)
|
||||
.borderRadius(2)
|
||||
.width(96 * this.ratio)
|
||||
@ -354,7 +365,8 @@ struct Index {
|
||||
.margin({ right: 10 * this.ratio })
|
||||
.fontSize(this.inputFontSize * this.ratio)
|
||||
.onChange((value: string) => {
|
||||
this.param['td'+(Number(index) + 1)] = value
|
||||
// this.param['td'+(Number(index) + 1)] = value
|
||||
this.setTdValue(Number(index) + 1, value)
|
||||
})
|
||||
TextInput({ text: this.param.userName, controller: this.inputController })
|
||||
.type(InputType.Normal)
|
||||
@ -578,21 +590,112 @@ struct Index {
|
||||
this.getVideoConfig()
|
||||
}
|
||||
|
||||
async getfilehandleCode(td) {
|
||||
return new Promise(async (reslove, reject) => {
|
||||
const record_handle = await startRecordVideo(this.param, td, this.context, 'lp')
|
||||
this.rocordHandleObj['rocord_handle'+td] = record_handle
|
||||
reslove(true)
|
||||
})
|
||||
async getFileHandleCode(td: number): Promise<void> {
|
||||
return new Promise<void>(async (resolve, reject) => {
|
||||
const record_handle: ESObject = await startRecordVideo(this.param, td, this.context, 'lp');
|
||||
this.setRecordHandle(td, record_handle);
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
getRecordHandle(index: number): ESObject {
|
||||
switch (index) {
|
||||
case 1:
|
||||
return this.rocordHandleObj.rocord_handle1;
|
||||
case 2:
|
||||
return this.rocordHandleObj.rocord_handle2;
|
||||
case 3:
|
||||
return this.rocordHandleObj.rocord_handle3;
|
||||
case 4:
|
||||
return this.rocordHandleObj.rocord_handle4;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
getVideoRecordValue(index: number): boolean {
|
||||
switch (index) {
|
||||
case 1:
|
||||
return this.param.videoRecord1;
|
||||
case 2:
|
||||
return this.param.videoRecord2;
|
||||
case 3:
|
||||
return this.param.videoRecord3;
|
||||
case 4:
|
||||
return this.param.videoRecord4;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
getTdValueByTd(td: string): string {
|
||||
switch (td) {
|
||||
case 'td1':
|
||||
return this.param.td1;
|
||||
case 'td2':
|
||||
return this.param.td2;
|
||||
case 'td3':
|
||||
return this.param.td3;
|
||||
case 'td4':
|
||||
return this.param.td4;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
getTdValueByIndex(index: number): string {
|
||||
switch (index) {
|
||||
case 1:
|
||||
return this.param.td1;
|
||||
case 2:
|
||||
return this.param.td2;
|
||||
case 3:
|
||||
return this.param.td3;
|
||||
case 4:
|
||||
return this.param.td4;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
setTdValue(index: number, value: string): void {
|
||||
switch (index) {
|
||||
case 1:
|
||||
this.param.td1 = value;
|
||||
break;
|
||||
case 2:
|
||||
this.param.td2 = value;
|
||||
break;
|
||||
case 3:
|
||||
this.param.td3 = value;
|
||||
break;
|
||||
case 4:
|
||||
this.param.td4 = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setRecordHandle(td: number, record_handle: ESObject): void {
|
||||
switch (td) {
|
||||
case 1:
|
||||
this.rocordHandleObj.rocord_handle1 = record_handle;
|
||||
break;
|
||||
case 2:
|
||||
this.rocordHandleObj.rocord_handle2 = record_handle;
|
||||
break;
|
||||
case 3:
|
||||
this.rocordHandleObj.rocord_handle3 = record_handle;
|
||||
break;
|
||||
case 4:
|
||||
this.rocordHandleObj.rocord_handle4 = record_handle;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
outClick() {
|
||||
this.openFlag = false
|
||||
}
|
||||
|
||||
sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
|
||||
|
||||
async onPageShow() {
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user