fix: VideoConfig.ets
This commit is contained in:
parent
438f3f3438
commit
6315aadc47
@ -70,3 +70,6 @@ export interface VideoConfig {
|
|||||||
zdyz: string,
|
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;
|
||||||
|
}
|
||||||
@ -7,3 +7,5 @@ export * from "./Common"
|
|||||||
export * from "./Judge"
|
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 { endRecordVideo, startRecordVideo, takePhoto } from '../service/videoService';
|
||||||
import { GlobalConfig } from '../config/index';
|
import { GlobalConfig } from '../config/index';
|
||||||
import { VideoConfigData } from '../mock';
|
import { VideoConfigData } from '../mock';
|
||||||
import { VideoConfig } from '../model';
|
import { CommonType, RecordHandleType, VideoConfig, VideoItemType } from '../model';
|
||||||
|
|
||||||
@Entry
|
@Entry
|
||||||
@Component
|
@Component
|
||||||
@ -15,7 +15,7 @@ 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: RecordHandleType = {
|
||||||
rocord_handle1: 0,
|
rocord_handle1: 0,
|
||||||
rocord_handle2: 0,
|
rocord_handle2: 0,
|
||||||
rocord_handle3: 0,
|
rocord_handle3: 0,
|
||||||
@ -30,7 +30,7 @@ struct Index {
|
|||||||
@State oldParam: VideoConfig = VideoConfigData
|
@State oldParam: VideoConfig = VideoConfigData
|
||||||
@State param: VideoConfig = VideoConfigData
|
@State param: VideoConfig = VideoConfigData
|
||||||
@State openFlag: boolean = true
|
@State openFlag: boolean = true
|
||||||
@State lsArr: Array<any> = [
|
@State lsArr: Array<CommonType> = [
|
||||||
{ key: '第一路' },
|
{ key: '第一路' },
|
||||||
{ key: '第二路' },
|
{ key: '第二路' },
|
||||||
{ key: '第三路' },
|
{ key: '第三路' },
|
||||||
@ -42,7 +42,7 @@ struct Index {
|
|||||||
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<VideoItemType> = [
|
||||||
{ 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: '' },
|
||||||
@ -55,10 +55,10 @@ struct Index {
|
|||||||
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: VideoItemType, index) => {
|
||||||
Video({
|
Video({
|
||||||
src: this.openFlag ?
|
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,
|
currentProgressRate: this.curRate,
|
||||||
controller: item.controller
|
controller: item.controller
|
||||||
@ -101,9 +101,14 @@ struct Index {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.videoStartFlag = true
|
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++) {
|
for (let i = 1; i <= 4; i++) {
|
||||||
if (this.param['videoRecord'+i]) {
|
if (this.getVideoRecordValue(i)) {
|
||||||
await this.getfilehandleCode(i)
|
await this.getFileHandleCode(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.videoStartFlag = false
|
this.videoStartFlag = false
|
||||||
@ -118,11 +123,17 @@ struct Index {
|
|||||||
|
|
||||||
.margin({ bottom: 10 * this.ratio })
|
.margin({ bottom: 10 * this.ratio })
|
||||||
.onClick(() => {
|
.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++) {
|
for (let i = 1; i <= 4; i++) {
|
||||||
console.log('rocord_handle', i, JSON.stringify(this.rocordHandleObj))
|
const handle: ESObject = this.getRecordHandle(i);
|
||||||
if (this.rocordHandleObj['rocord_handle'+i]) {
|
if (handle) {
|
||||||
endRecordVideo(this.rocordHandleObj['rocord_handle'+i])
|
endRecordVideo(handle);
|
||||||
this.rocordHandleObj['rocord_handle'+i] = 0
|
this.setRecordHandle(i, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
promptAction.showToast({
|
promptAction.showToast({
|
||||||
@ -327,7 +338,7 @@ struct Index {
|
|||||||
.textAlign(TextAlign.Center)
|
.textAlign(TextAlign.Center)
|
||||||
}
|
}
|
||||||
|
|
||||||
ForEach(this.lsArr, (item, index) => {
|
ForEach(this.lsArr, (item: CommonType, index) => {
|
||||||
Row() {
|
Row() {
|
||||||
Text(item.key)
|
Text(item.key)
|
||||||
.width(70 * this.ratio)
|
.width(70 * this.ratio)
|
||||||
@ -345,7 +356,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.getTdValueByIndex((Number(index) + 1)), controller: this.inputController })
|
||||||
.type(InputType.Normal)
|
.type(InputType.Normal)
|
||||||
.borderRadius(2)
|
.borderRadius(2)
|
||||||
.width(96 * this.ratio)
|
.width(96 * this.ratio)
|
||||||
@ -354,7 +365,8 @@ 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
|
||||||
|
this.setTdValue(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)
|
||||||
@ -578,21 +590,112 @@ struct Index {
|
|||||||
this.getVideoConfig()
|
this.getVideoConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
async getfilehandleCode(td) {
|
async getFileHandleCode(td: number): Promise<void> {
|
||||||
return new Promise(async (reslove, reject) => {
|
return new Promise<void>(async (resolve, reject) => {
|
||||||
const record_handle = await startRecordVideo(this.param, td, this.context, 'lp')
|
const record_handle: ESObject = await startRecordVideo(this.param, td, this.context, 'lp');
|
||||||
this.rocordHandleObj['rocord_handle'+td] = record_handle
|
this.setRecordHandle(td, record_handle);
|
||||||
reslove(true)
|
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() {
|
outClick() {
|
||||||
this.openFlag = false
|
this.openFlag = false
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
|
|
||||||
|
|
||||||
async onPageShow() {
|
async onPageShow() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user