提交 78c3aa20 编写于 作者: 1 15754133731

<媒体validatorPlayer修改>

Signed-off-by: N15754133731 <chenjiahuan@huawei.com>
上级 7606f7b5
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { CustomContainer } from '../common/AudioContainer'; import { CustomContainer } from '../common/AudioContainer';
import FirstDialog from '../model/FirstDialog'; import FirstDialog from '../model/FirstDialog';
import router from '@ohos.router'; import router from '@ohos.router';
...@@ -21,14 +21,14 @@ import router from '@ohos.router'; ...@@ -21,14 +21,14 @@ import router from '@ohos.router';
@Component @Component
struct playAudio { struct playAudio {
@State FillColor: string = '#FF000000'; @State FillColor: string = '#FF000000';
@State name: string = 'PlayAudio'; @State name: string = router.getParams()['audioTitle']
@State StepTips: string = '测试目的:用于测试音频播放暂停seek\n预期结果:音频播放暂停seek功能正常'; @State StepTips: string = '测试目的:用于测试音频播放暂停seek\n预期结果:音频播放暂停seek功能正常';
private tag: string = 'qlw' private tag: string = 'qlw';
@State Vue: boolean = false @State Vue: boolean = false;
@State videoSrc: Resource = $rawfile('StarWars10s-1C-44100-2SW.wav') @State audioSrc: string = router.getParams()['audioUrl'];
@State isAutoPlay: boolean = true @State isAutoPlay: boolean = true;
@State showControls: boolean = true @State showControls: boolean = true;
controller: VideoController = new VideoController() controller: VideoController = new VideoController();
async aboutToAppear() { async aboutToAppear() {
await FirstDialog.ChooseDialog(this.StepTips, this.name); await FirstDialog.ChooseDialog(this.StepTips, this.name);
...@@ -42,7 +42,7 @@ struct playAudio { ...@@ -42,7 +42,7 @@ struct playAudio {
}.backgroundColor(Color.Black) }.backgroundColor(Color.Black)
.onClick(() => { .onClick(() => {
router.back({ router.back({
url: 'pages/Player/Player_index', url: 'pages/Player/PlayAudioList',
params: { result: 'None', } params: { result: 'None', }
}) })
}) })
...@@ -53,32 +53,33 @@ struct playAudio { ...@@ -53,32 +53,33 @@ struct playAudio {
Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Video({ Video({
src: this.videoSrc, src: this.audioSrc,
controller: this.controller controller: this.controller
}) })
.width('100%') .width('100%')
.height('60%') .height('60%')
.autoPlay(this.isAutoPlay) .autoPlay(this.isAutoPlay)
.controls(this.showControls) .controls(this.showControls)
.onFinish(() => { .onFinish(() => {
this.Vue = true this.Vue = true;
}) })
}.width('100%').height('80%').onClick(() => { }.width('100%').height('80%').onClick(() => {
this.showControls = !this.showControls this.showControls = !this.showControls;
}) })
CustomContainer({ CustomContainer({
title: this.name, title: this.name,
Url: 'pages/Player/Player_index', Url: 'pages/Player/PlayAudioList',
StepTips: this.StepTips, StepTips: this.StepTips,
name: $name, name: $name,
Vue: $Vue Vue: $Vue
}).height('10%').width('100%') }).height('10%').width('100%')
}.width('100%').height('100%').backgroundColor(Color.Black) }.width('100%').height('100%').backgroundColor(Color.Black)
} }
onBackPress(){
onBackPress() {
router.replaceUrl({ router.replaceUrl({
url:'pages/Player/Player_index', url: 'pages/Player/PlayAudioList',
}) })
} }
} }
\ No newline at end of file
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import prompt from '@ohos.prompt';
import router from '@ohos.router';
import fileio from '@ohos.fileio';
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import data_preferences from '@ohos.data.preferences';
import MediaUtils from '../model/MediaUtils'
const TAG = 'ParseXML';
let path = globalThis.dir;
let path1 = path + '/Player';
let VarColor = [];
let ColorBackPath = path1 + '/PlayerAudioColorBack.txt';
let txtPath = path1 + '/PlayerAudioReport.txt';
@Entry
@Component
struct audioNew {
@State ClearAll: boolean = false;
@State name: string = 'PlayerAudio';
@State Vue: boolean = false;
private current: number = undefined;
@State MediaLib: MediaUtils = new MediaUtils();
@State count: number = 0;
@State result: string = '';
@State TEST: number = 0;
@State Url: string = '';
@State TestCaseList: Array<mediaLibrary.FileAsset> = [];
@State ColorObject: string[] = VarColor;
async aboutToAppear() {
this.getAudioData();
}
async getAudioData() {
this.TestCaseList = await this.MediaLib.getFileAssetsAlbum('Audios/ValidatorData/');
}
async onPageShow() {
let Test = null;
let context = null;
context = globalThis.getContext();
let preferences;
let promise = data_preferences.getPreferences(context, 'mystore');
await promise.then((object) => {
preferences = object;
});
promise = preferences.get('PlayerAudio', 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'PlayerAudio'. Data: " + data);
});
if (Test != 1) {
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for (let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].displayName + ';' + '#ff808080' + ';').toString();
fileio.writeSync(fd, log);
}
fileio.closeSync(fd);
}
promise = preferences.put('PlayerAudio', 1);
promise.then(() => {
console.info("Succeeded in putting value of 'PlayerAudio'.");
});
promise = preferences.flush();
promise.then(() => {
console.info("Succeeded in flushing.");
});
this.TEST = Test;
let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664);
let buff = new ArrayBuffer(40960);
fileio.readSync(opt, buff);
let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff));
let TestList = ColorBack.split(';');
for (let i = 0; i < Math.floor(TestList.length / 2); i++) {
VarColor[i] = TestList[i * 2+1];
}
fileio.closeSync(opt);
if (this.count === 1) {
this.result = router.getParams()['result'];
let titles = router.getParams()['title'];
let name1 = '刚刚点进了哪个用例:' + titles;
let results = this.result;
let WriteTitle = (titles).toString();
let number = WriteTitle.length + 11;
let Index = ColorBack.indexOf(WriteTitle);
if (this.result === 'true') {
this.ColorObject[this.current] = '#ff008000';
let Log = (titles + ';' + '#ff008000' + ';');
let key = ColorBack.substring(Index, Index + number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key, Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD, buffer);
let Report = ColorBack.substring(0, rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
fileio.writeSync(Fd, Report);
filewrite(name1, results, titles);
}
else if (this.result === 'false') {
this.ColorObject[this.current] = '#ffff0000';
let Log = (titles + ';' + '#ffff0000' + ';');
let key = ColorBack.substring(Index, Index + number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key, Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD, buffer);
let Report = ColorBack.substring(0, rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
fileio.writeSync(Fd, Report);
filewrite(name1, results, titles);
}
else if (this.result === 'None') {
this.ColorObject[this.current] = this.ColorObject[this.current];
}
}
// 所有测试项满足返回ture
let color = '#ff008000';
let colorBol = this.ColorObject.every((item) => item === color);
this.Vue = colorBol;
}
build() {
Column() {
Row() {
Button() {
Image($r('app.media.ic_public_back')).width('20vp').height('18vp')
}.backgroundColor(Color.Black).size({ width: '40vp', height: '30vp' })
.onClick(() => {
router.back({
url: 'pages/Player/Player_index',
params: { result: 'None', }
})
})
Row() {
Text('Player Audio')
.fontColor(Color.White)
.fontSize('22fp')
}.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black)
Row() {
Button() {
Image($r('app.media.ic_public_delete'))
.width('30vp')
.height('30vp')
}.backgroundColor(Color.Black)
.onClick(() => {
AlertDialog.show(
{
message: "是否删除所有记录",
primaryButton: {
value: 'Yes',
action: () => {
this.ClearAll = true;
this.ColorObject.forEach((value, index) => {
this.ColorObject[index] = '#ff808080';
});
this.ClearText();
prompt.showToast({
message: '结果已删除', duration: 1000
});
}
},
secondaryButton: {
value: 'No',
action: () => {
}
},
cancel: () => {
}
}
)
})
}
}
.width('100%')
.justifyContent(FlexAlign.SpaceAround)
.margin({ top: '15vp' })
.height('6%')
.backgroundColor(Color.Black)
List({ space: 5 }) {
ForEach(this.TestCaseList, (item: mediaLibrary.FileAsset, index) => {
ListItem() {
Row() {
Text(item.displayName).fontSize(16).fontColor(Color.Black)
}
.width('100%')
.height(50)
.alignItems(VerticalAlign.Center)
.backgroundColor(this.count === 0 && this.TEST === 0 ? '#ff808080' : this.ColorObject[index])
.onClick(() => {
this.count = 1;
this.ClearAll = false;
this.current = index;
router.push({
url: 'pages/Player/PlayAudio',
params: {
audioUrl: item.uri,
audioTitle: item.displayName
}
})
})
}
}, item => item.title)
}.width('100%').height('80%')
Row() {
Blank()
Button() {
Image($r('app.media.ic_public_pass')).width('20vp').height('20vp')
}
.width('40%')
.height('30vp')
.backgroundColor(Color.Grey)
.enabled(this.Vue)
.opacity(this.Vue ? 1 : 0.4)
.onClick(() => {
router.back({
url: 'pages/Player/Player_index',
params: { result: 'true', title: this.name,
}
})
prompt.showToast({
message: '通过', duration: 1000
});
})
Blank().width(40)
Button() {
Image($r('app.media.ic_public_fail')).width('20vp').height('20vp')
}.width('40%').height('30vp').backgroundColor(Color.Grey)
.onClick(() => {
router.back({
url: 'pages/Player/Player_index',
params: { result: 'false', title: this.name,
}
})
console.log('wwwwwwwwww' + this.Url)
prompt.showToast({
message: '失败', duration: 1000
});
})
Blank()
}.width('100%').height('14%').backgroundColor(Color.Black).justifyContent(FlexAlign.Center)
}.width('100%').height('100%').backgroundColor(Color.Black)
}
ClearText() {
fileio.rmdirSync(path1);
fileio.mkdirSync(path1);
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for (let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].displayName + ';' + '#ff808080' + ';').toString();
fileio.writeSync(fd, log);
}
}
onBackPress() {
router.replaceUrl({
url: 'pages/Player/Player_index',
})
}
}
function filewrite(name1, results, titles) {
let fd = fileio.openSync(txtPath, 0o100 | 0o2002, 0o664);
let buf = new ArrayBuffer(4096);
let RD = fileio.readSync(fd, buf);
console.info("RRRRRRRRRRd" + RD);
let report = String.fromCharCode.apply(null, new Uint8Array(buf));
let WriteTitle = (titles).toString();
let WriteResult = (results).toString();
let number = WriteTitle.length + WriteResult.length + 2;
let Index = report.indexOf(WriteTitle);
let Log = (titles + ";" + results + ";").toString();
if (Index == -1) {
fileio.writeSync(fd, Log);
}
else if (Index != -1) {
let key = report.substring(Index, Index + number);
let FD = fileio.openSync(txtPath, 0o102, 0o666);
report = report.replace(key, Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD, buffer);
let Report = report.substring(0, rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(txtPath, 0o102, 0o666);
fileio.writeSync(Fd, Report);
}
}
\ No newline at end of file
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import { CustomContainer } from '../common/AudioContainer'; import { CustomContainer } from '../common/AudioContainer';
import FirstDialog from '../model/FirstDialog'; import FirstDialog from '../model/FirstDialog';
...@@ -22,14 +22,14 @@ import router from '@ohos.router'; ...@@ -22,14 +22,14 @@ import router from '@ohos.router';
@Component @Component
struct playVideo { struct playVideo {
@State FillColor: string = '#FF000000'; @State FillColor: string = '#FF000000';
@State name: string = 'PlayVideo'; @State name: string = router.getParams()['audioTitle'];
@State StepTips: string = '测试目的:用于测试视频播放暂停seek\n预期结果:视频播放暂停seek功能正常'; @State StepTips: string = '测试目的:用于测试视频播放暂停seek\n预期结果:视频播放暂停seek功能正常';
private tag: string = 'qlw' private tag: string = 'qlw';
@State Vue: boolean = false @State Vue: boolean = false;
@State videoSrc: Resource = $rawfile('H264_AAC.mkv') @State videoSrc: Resource = $rawfile('H264_AAC.mkv');
@State isAutoPlay: boolean = true @State isAutoPlay: boolean = true;
@State showControls: boolean = true @State showControls: boolean = true;
controller: VideoController = new VideoController() controller: VideoController = new VideoController();
async aboutToAppear() { async aboutToAppear() {
await FirstDialog.ChooseDialog(this.StepTips, this.name); await FirstDialog.ChooseDialog(this.StepTips, this.name);
...@@ -43,7 +43,7 @@ struct playVideo { ...@@ -43,7 +43,7 @@ struct playVideo {
}.backgroundColor(Color.Black) }.backgroundColor(Color.Black)
.onClick(() => { .onClick(() => {
router.back({ router.back({
url: 'pages/Player/Player_index', url: 'pages/Player/PlayVideoList',
params: { result: 'None', } params: { result: 'None', }
}) })
}) })
...@@ -61,25 +61,26 @@ struct playVideo { ...@@ -61,25 +61,26 @@ struct playVideo {
.height('60%') .height('60%')
.autoPlay(this.isAutoPlay) .autoPlay(this.isAutoPlay)
.controls(this.showControls) .controls(this.showControls)
.onFinish(() => { .onFinish(() => {
this.Vue = true this.Vue = true;
}) })
}.width('100%').height('80%').onClick(() => { }.width('100%').height('80%').onClick(() => {
this.showControls = !this.showControls this.showControls = !this.showControls
}) })
CustomContainer({ CustomContainer({
title: this.name, title: this.name,
Url: 'pages/Player/Player_index', Url: 'pages/Player/PlayVideoList',
StepTips: this.StepTips, StepTips: this.StepTips,
name: $name, name: $name,
Vue: $Vue Vue: $Vue
}).height('10%').width('100%') }).height('10%').width('100%')
}.width('100%').height('100%').backgroundColor(Color.Black) }.width('100%').height('100%').backgroundColor(Color.Black)
} }
onBackPress(){
onBackPress() {
router.replaceUrl({ router.replaceUrl({
url:'pages/Player/Player_index', url: 'pages/Player/PlayVideoList',
}) })
} }
} }
\ No newline at end of file
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import prompt from '@ohos.prompt';
import router from '@ohos.router';
import fileio from '@ohos.fileio';
import mediaLibrary from '@ohos.multimedia.mediaLibrary'
import data_preferences from '@ohos.data.preferences';
import MediaUtils from '../model/MediaUtils'
const TAG = 'ParseXML';
let path = globalThis.dir;
let path1 = path + '/Player';
let VarColor = [];
let ColorBackPath = path1 + '/PlayerVideoColorBack.txt';
let txtPath = path1 + '/PlayerVideoReport.txt';
@Entry
@Component
struct videoNew {
@State ClearAll: boolean = false;
@State name: string = 'PlayerVideo';
@State Vue: boolean = false;
private current: number = undefined;
@State MediaLib: MediaUtils = new MediaUtils();
@State count: number = 0;
@State result: string = '';
@State TEST: number = 0;
@State Url: string = 'pages/Player/Player_index';
@State TestCaseList: Array<mediaLibrary.FileAsset> = [];
@State ColorObject: string[] = VarColor;
async aboutToAppear() {
this.getVideoData();
}
async getVideoData() {
this.TestCaseList = await this.MediaLib.getFileAssetsAlbum('Videos/ValidatorData/');
}
async onPageShow() {
let Test = null;
let context = null;
context = globalThis.getContext();
let preferences;
let promise = data_preferences.getPreferences(context, 'mystore');
await promise.then((object) => {
preferences = object;
});
promise = preferences.get('PlayerVideo', 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'PlayerVideo'. Data: " + data);
});
if (Test != 1) {
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for (let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].displayName + ';' + '#ff808080' + ';').toString();
fileio.writeSync(fd, log);
}
fileio.closeSync(fd);
}
promise = preferences.put('PlayerVideo', 1);
promise.then(() => {
console.info("Succeeded in putting value of 'PlayerVideo'.");
});
promise = preferences.flush();
promise.then(() => {
console.info("Succeeded in flushing.");
});
this.TEST = Test;
let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664);
let buff = new ArrayBuffer(40960);
fileio.readSync(opt, buff);
let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff));
let TestList = ColorBack.split(';');
for (let i = 0; i < Math.floor(TestList.length / 2); i++) {
VarColor[i] = TestList[i * 2+1];
}
fileio.closeSync(opt);
if (this.count === 1) {
this.result = router.getParams()['result'];
let titles = router.getParams()['title'];
let name1 = '刚刚点进了哪个用例:' + titles;
let results = this.result;
let WriteTitle = (titles).toString();
let number = WriteTitle.length + 11;
let Index = ColorBack.indexOf(WriteTitle);
if (this.result === 'true') {
this.ColorObject[this.current] = '#ff008000';
let Log = (titles + ';' + '#ff008000' + ';');
let key = ColorBack.substring(Index, Index + number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key, Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD, buffer);
let Report = ColorBack.substring(0, rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
fileio.writeSync(Fd, Report);
filewrite(name1, results, titles)
}
else if (this.result === 'false') {
this.ColorObject[this.current] = '#ffff0000';
let Log = (titles + ';' + '#ffff0000' + ';');
let key = ColorBack.substring(Index, Index + number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key, Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD, buffer);
let Report = ColorBack.substring(0, rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
fileio.writeSync(Fd, Report);
filewrite(name1, results, titles);
}
else if (this.result === 'None') {
this.ColorObject[this.current] = this.ColorObject[this.current];
}
}
// 所有测试项满足返回ture
let color = '#ff008000';
let colorBol = this.ColorObject.every((item) => item === color);
this.Vue = colorBol;
}
build() {
Column() {
Row() {
Button() {
Image($r('app.media.ic_public_back')).width('20vp').height('18vp')
}.backgroundColor(Color.Black).size({ width: '40vp', height: '30vp' })
.onClick(() => {
router.back({
url: 'pages/Player/Player_index',
params: { result: 'None', }
})
})
Row() {
Text('Player Video')
.fontColor(Color.White)
.fontSize('22fp')
}.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black)
Row() {
Button() {
Image($r('app.media.ic_public_delete'))
.width('30vp')
.height('30vp')
}.backgroundColor(Color.Black)
.onClick(() => {
AlertDialog.show(
{
message: "是否删除所有记录",
primaryButton: {
value: 'Yes',
action: () => {
this.ClearAll = true;
this.ColorObject.forEach((value, index) => {
this.ColorObject[index] = '#ff808080';
});
this.ClearText();
prompt.showToast({
message: '结果已删除', duration: 1000
});
}
},
secondaryButton: {
value: 'No',
action: () => {
}
},
cancel: () => {
}
}
)
})
}
}
.width('100%')
.justifyContent(FlexAlign.SpaceAround)
.margin({ top: '15vp' })
.height('6%')
.backgroundColor(Color.Black)
List({ space: 5 }) {
ForEach(this.TestCaseList, (item: mediaLibrary.FileAsset, index) => {
ListItem() {
Row() {
Text(item.displayName).fontSize(16).fontColor(Color.Black)
}
.width('100%')
.height(50)
.alignItems(VerticalAlign.Center)
.backgroundColor(this.count === 0 && this.TEST === 0 ? '#ff808080' : this.ColorObject[index])
.onClick(() => {
this.count = 1;
this.ClearAll = false;
this.current = index;
router.push({
url: 'pages/Player/PlayVideo',
params: {
audioUrl: item.uri,
audioTitle: item.displayName
}
})
})
}
}, item => item.title)
}.width('100%').height('80%')
Row() {
Blank()
Button({ stateEffect: this.Vue }) {
Image($r('app.media.ic_public_pass')).width('20vp').height('20vp')
}
.width('40%')
.height('30vp')
.backgroundColor(Color.Grey)
.enabled(this.Vue)
.opacity(this.Vue ? 1 : 0.4)
.onClick(() => {
router.back({
url: this.Url,
params: { result: 'true', title: this.name,
}
})
prompt.showToast({
message: '通过', duration: 1000
});
})
Blank().width(40)
Button() {
Image($r('app.media.ic_public_fail')).width('20vp').height('20vp')
}.width('40%').height('30vp').backgroundColor(Color.Grey)
.onClick(() => {
router.back({
url: this.Url,
params: { result: 'false', title: this.name,
}
})
console.log('wwwwwwwwww' + this.Url)
prompt.showToast({
message: '失败', duration: 1000
});
})
Blank()
}.width('100%').height('14%').backgroundColor(Color.Black).justifyContent(FlexAlign.Center)
}.width('100%').height('100%').backgroundColor(Color.Black)
}
ClearText() {
fileio.rmdirSync(path1);
fileio.mkdirSync(path1);
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for (let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].displayName + ';' + '#ff808080' + ';').toString();
fileio.writeSync(fd, log);
}
}
onBackPress() {
router.replaceUrl({
url: 'pages/Player/Player_index',
})
}
}
function filewrite(name1, results, titles) {
let fd = fileio.openSync(txtPath, 0o100 | 0o2002, 0o664);
let buf = new ArrayBuffer(4096);
let RD = fileio.readSync(fd, buf);
console.info("RRRRRRRRRRd" + RD);
let report = String.fromCharCode.apply(null, new Uint8Array(buf));
let WriteTitle = (titles).toString();
let WriteResult = (results).toString();
let number = WriteTitle.length + WriteResult.length + 2;
let Index = report.indexOf(WriteTitle);
let Log = (titles + ";" + results + ";").toString();
if (Index == -1) {
fileio.writeSync(fd, Log);
}
else if (Index != -1) {
let key = report.substring(Index, Index + number);
let FD = fileio.openSync(txtPath, 0o102, 0o666);
report = report.replace(key, Log);
let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD, buffer);
let Report = report.substring(0, rd);
fileio.closeSync(FD);
let Fd = fileio.openSync(txtPath, 0o102, 0o666);
fileio.writeSync(Fd, Report);
}
}
\ No newline at end of file
...@@ -20,6 +20,7 @@ import xml from '@ohos.xml'; ...@@ -20,6 +20,7 @@ import xml from '@ohos.xml';
import fileIO from '@ohos.fileio'; import fileIO from '@ohos.fileio';
import util from '@ohos.util'; import util from '@ohos.util';
import data_preferences from '@ohos.data.preferences'; import data_preferences from '@ohos.data.preferences';
import FlushData from '../model/FlushData';
const TAG = 'ParseXML'; const TAG = 'ParseXML';
let path = globalThis.dir; let path = globalThis.dir;
...@@ -28,28 +29,29 @@ let path1 = path + '/Player'; ...@@ -28,28 +29,29 @@ let path1 = path + '/Player';
let VarColor = []; let VarColor = [];
let ColorBackPath = path + '/PlayerColorBack.txt'; let ColorBackPath = path + '/PlayerColorBack.txt';
let txtPath = path1 + '/PlayerReport.txt'; let txtPath = path1 + '/PlayerReport.txt';
let xmlPath =path1 + '/PlayerTest.xml'; let xmlPath = path1 + '/PlayerTest.xml';
@Entry @Entry
@Component @Component
struct IndexPage { struct IndexPage {
@State ClearAll : boolean = false; @State ClearAll: boolean = false;
private current : number = undefined; private current: number = undefined;
@State count : number = 0; @State count: number = 0;
@State result : string = ''; @State result: string = '';
@State TEST : number = 0; @State TEST: number = 0;
private TestCaseList = [ private TestCaseList = [
{title:'PlayAudio',uri:'pages/Player/PlayAudio'}, { title: 'PlayerAudio', uri: 'pages/Player/PlayAudioList' },
{title:'PlayVideo',uri:'pages/Player/PlayVideo'}, { title: 'PlayerVideo', uri: 'pages/Player/PlayVideoList' },
] ]
@State ColorObject : string[] = VarColor; @State ColorObject: string[] = VarColor;
async onPageShow(){
async onPageShow() {
let Test = null; let Test = null;
let context =null; let context = null;
context = globalThis.getContext(); context = globalThis.getContext();
let preferences; let preferences;
let promise = data_preferences.getPreferences(context,'mystore'); let promise = data_preferences.getPreferences(context, 'mystore');
await promise.then((object) => { await promise.then((object) => {
preferences = object; preferences = object;
}); });
...@@ -59,11 +61,11 @@ struct IndexPage { ...@@ -59,11 +61,11 @@ struct IndexPage {
console.info("Succeeded in getting value of 'Player'. Data: " + data); console.info("Succeeded in getting value of 'Player'. Data: " + data);
}); });
if(Test != 1) { if (Test != 1) {
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) { for (let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); let log = (this.TestCaseList[i].title + ';' + '#ff808080' + ';').toString();
fileio.writeSync(fd,log); fileio.writeSync(fd, log);
} }
fileio.closeSync(fd); fileio.closeSync(fd);
} }
...@@ -79,58 +81,60 @@ struct IndexPage { ...@@ -79,58 +81,60 @@ struct IndexPage {
let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664); let opt = fileio.openSync(ColorBackPath, 0o100 | 0o2002, 0o664);
let buff = new ArrayBuffer(40960); let buff = new ArrayBuffer(40960);
fileio.readSync(opt,buff); fileio.readSync(opt, buff);
let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff)); let ColorBack = String.fromCharCode.apply(null, new Uint8Array(buff));
let TestList = ColorBack.split(';'); let TestList = ColorBack.split(';');
for (let i = 0; i < Math.floor(TestList.length / 2); i++) { for (let i = 0; i < Math.floor(TestList.length / 2); i++) {
VarColor[i] = TestList[i*2+1]; VarColor[i] = TestList[i * 2+1];
} }
fileio.closeSync(opt); fileio.closeSync(opt);
if (this.count === 1){ if (this.count === 1) {
this.result = router.getParams()['result']; this.result = router.getParams()['result'];
let titles = router.getParams()['title']; let titles = router.getParams()['title'];
let name1 = '刚刚点进了哪个用例:'+ titles; let name1 = '刚刚点进了哪个用例:' + titles;
let results = this.result; let results = this.result;
let WriteTitle = (titles).toString(); let WriteTitle = (titles).toString();
let number = WriteTitle.length + 11; let number = WriteTitle.length + 11;
let Index = ColorBack.indexOf(WriteTitle); let Index = ColorBack.indexOf(WriteTitle);
if (this.result === 'true'){ if (this.result === 'true') {
this.ColorObject[this.current] = '#ff008000'; this.ColorObject[this.current] = '#ff008000';
let Log = (titles+';'+'#ff008000'+';'); let Log = (titles + ';' + '#ff008000' + ';');
let key = ColorBack.substring(Index,Index+number); let key = ColorBack.substring(Index, Index + number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log); ColorBack = ColorBack.replace(key, Log);
let buffer = new ArrayBuffer(4096); let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD,buffer); let rd = fileio.readSync(FD, buffer);
let Report = ColorBack.substring(0,rd); let Report = ColorBack.substring(0, rd);
fileio.closeSync(FD); fileio.closeSync(FD);
let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
fileio.writeSync(Fd,Report); fileio.writeSync(Fd, Report);
filewrite(name1,results,titles) filewrite(name1, results, titles)
} }
else if (this.result === 'false'){ else if (this.result === 'false') {
this.ColorObject[this.current] = '#ffff0000'; this.ColorObject[this.current] = '#ffff0000';
let Log = (titles+';'+'#ffff0000'+';'); let Log = (titles + ';' + '#ffff0000' + ';');
let key = ColorBack.substring(Index,Index+number); let key = ColorBack.substring(Index, Index + number);
let FD = fileio.openSync(ColorBackPath, 0o102, 0o666); let FD = fileio.openSync(ColorBackPath, 0o102, 0o666);
ColorBack = ColorBack.replace(key,Log); ColorBack = ColorBack.replace(key, Log);
let buffer = new ArrayBuffer(4096); let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD,buffer); let rd = fileio.readSync(FD, buffer);
let Report = ColorBack.substring(0,rd); let Report = ColorBack.substring(0, rd);
fileio.closeSync(FD); fileio.closeSync(FD);
let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let Fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
fileio.writeSync(Fd,Report); fileio.writeSync(Fd, Report);
filewrite(name1,results,titles); filewrite(name1, results, titles);
} }
else if (this.result === 'None'){ else if (this.result === 'None') {
this.ColorObject[this.current] = this.ColorObject[this.current]; this.ColorObject[this.current] = this.ColorObject[this.current];
} }
} }
} }
build(){
Column(){ build() {
Column() {
Row() { Row() {
Button() { Button() {
Image($r('app.media.ic_public_back')).width('20vp').height('18vp') Image($r('app.media.ic_public_back')).width('20vp').height('18vp')
...@@ -138,13 +142,15 @@ struct IndexPage { ...@@ -138,13 +142,15 @@ struct IndexPage {
.onClick(() => { .onClick(() => {
router.back(); router.back();
}) })
Row(){
Row() {
Text('Player SubSystem') Text('Player SubSystem')
.fontColor(Color.White) .fontColor(Color.White)
.fontSize('22fp') .fontSize('22fp')
}.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black) }.justifyContent(FlexAlign.SpaceAround).backgroundColor(Color.Black)
Row() { Row() {
Button(){ Button() {
Image($r('app.media.ic_public_delete')) Image($r('app.media.ic_public_delete'))
.width('30vp') .width('30vp')
.height('30vp') .height('30vp')
...@@ -158,7 +164,7 @@ struct IndexPage { ...@@ -158,7 +164,7 @@ struct IndexPage {
action: () => { action: () => {
this.ClearAll = true; this.ClearAll = true;
this.ColorObject.forEach((value, index) => { this.ColorObject.forEach((value, index) => {
this.ColorObject[index] = '#ff808080'; this.ColorObject[index] = '#ff808080';
}); });
this.ClearText(); this.ClearText();
prompt.showToast({ prompt.showToast({
...@@ -178,7 +184,8 @@ struct IndexPage { ...@@ -178,7 +184,8 @@ struct IndexPage {
} }
) )
}) })
Button(){
Button() {
Image($r('app.media.ic_public_save')) Image($r('app.media.ic_public_save'))
.width('30vp') .width('30vp')
.height('30vp') .height('30vp')
...@@ -188,9 +195,9 @@ struct IndexPage { ...@@ -188,9 +195,9 @@ struct IndexPage {
this.ReadTextParseXml(); this.ReadTextParseXml();
AlertDialog.show({ AlertDialog.show({
message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/Player/PlayerTest.xml -本地路径'", message: "报告已生成,如需查看通过命令行输入'hdc_std file recv /data/app/el2/100/base/com.example.actsvalidator/haps/entry/files/Player/PlayerTest.xml -本地路径'",
confirm:{ confirm: {
value:'OK', value: 'OK',
action:()=>{ action: () => {
prompt.showToast({ prompt.showToast({
message: '报告已生成', duration: 1000 message: '报告已生成', duration: 1000
}) })
...@@ -204,62 +211,78 @@ struct IndexPage { ...@@ -204,62 +211,78 @@ struct IndexPage {
}) })
}) })
} }
}.width('100%').justifyContent(FlexAlign.SpaceAround).margin({top:'15vp'}).height('6%').backgroundColor(Color.Black) }
List({space:5}){ .width('100%')
ForEach(this.TestCaseList,(item,index) => { .justifyContent(FlexAlign.SpaceAround)
ListItem(){ .margin({ top: '15vp' })
Row(){ .height('6%')
.backgroundColor(Color.Black)
List({ space: 5 }) {
ForEach(this.TestCaseList, (item, index) => {
ListItem() {
Row() {
Text(item.title).fontSize(16).fontColor(Color.Black) Text(item.title).fontSize(16).fontColor(Color.Black)
}.width('100%').height(50).alignItems(VerticalAlign.Center).backgroundColor(this.count===0&&this.TEST===0?'#ff808080':this.ColorObject[index]) }
.onClick(( )=>{ .width('100%')
.height(50)
.alignItems(VerticalAlign.Center)
.backgroundColor(this.count === 0 && this.TEST === 0 ? '#ff808080' : this.ColorObject[index])
.onClick(() => {
this.count = 1; this.count = 1;
this.ClearAll=false; this.ClearAll = false;
this.current = index; this.current = index;
router.push({ router.push({
url: item.uri, url: item.uri,
}) })
}) })
} }
},item => item.title) }, item => item.title)
}.width('100%').height('92%') }.width('100%').height('92%')
}.width('100%').height('100%').backgroundColor(Color.Black) }.width('100%').height('100%').backgroundColor(Color.Black)
} }
ClearText(){
ClearText() {
fileio.rmdirSync(path1); fileio.rmdirSync(path1);
fileio.mkdirSync(path1); fileio.mkdirSync(path1);
let fd = fileio.openSync(ColorBackPath, 0o102, 0o666); let fd = fileio.openSync(ColorBackPath, 0o102, 0o666);
for(let i = 0; i < this.TestCaseList.length; i++) { for (let i = 0; i < this.TestCaseList.length; i++) {
let log = (this.TestCaseList[i].title+';'+'#ff808080'+';').toString(); let log = (this.TestCaseList[i].title + ';' + '#ff808080' + ';').toString();
fileio.writeSync(fd,log); fileio.writeSync(fd, log);
} }
FlushData.ResetPlayerAudio();
FlushData.ResetPlayerVideo();
} }
ReadTextParseXml(){
ReadTextParseXml() {
let ReportPath = path1 + '/PlayerReport.txt'; let ReportPath = path1 + '/PlayerReport.txt';
let dir = fileio.opendirSync(path1); let dir = fileio.opendirSync(path1);
console.info("ssssss"+dir); console.info("ssssss" + dir);
while (dir) { while (dir) {
let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664); let OP = fileio.openSync(ReportPath, 0o100 | 0o2002, 0o664);
let buf = new ArrayBuffer(40960); let buf = new ArrayBuffer(40960);
let RD = fileio.readSync(OP,buf); let RD = fileio.readSync(OP, buf);
console.info("ddddd"+RD); console.info("ddddd" + RD);
let report; let report;
function ab2str(buf) { function ab2str(buf) {
return report = String.fromCharCode.apply(null,new Uint8Array(buf)); return report = String.fromCharCode.apply(null, new Uint8Array(buf));
} }
ab2str(buf); ab2str(buf);
let str1 = report.split(";"); let str1 = report.split(";");
let title = []; let title = [];
let result = []; let result = [];
for(let i=0; i<Math.floor(str1.length/2); i++){ for (let i = 0; i < Math.floor(str1.length / 2); i++) {
title[i] = str1[i*2]; title[i] = str1[i*2];
result[i] = str1[i*2+1]; result[i] = str1[i * 2+1];
} }
let FailIndex = report.indexOf('false'); let FailIndex = report.indexOf('false');
let FailNum = 0; let FailNum = 0;
while (FailIndex != -1) { while (FailIndex != -1) {
console.log(FailIndex); console.log(FailIndex);
FailNum++; FailNum++;
FailIndex = report.indexOf('false',FailIndex + 1); FailIndex = report.indexOf('false', FailIndex + 1);
} }
let failNum = (FailNum).toString(); let failNum = (FailNum).toString();
let PassIndex = report.indexOf('true'); let PassIndex = report.indexOf('true');
...@@ -267,7 +290,7 @@ struct IndexPage { ...@@ -267,7 +290,7 @@ struct IndexPage {
while (PassIndex != -1) { while (PassIndex != -1) {
console.log(PassIndex); console.log(PassIndex);
PassNum++; PassNum++;
PassIndex = report.indexOf('true',PassIndex + 1); PassIndex = report.indexOf('true', PassIndex + 1);
} }
let TestNum = FailNum + PassNum; let TestNum = FailNum + PassNum;
let testNum = (TestNum).toString(); let testNum = (TestNum).toString();
...@@ -276,7 +299,7 @@ struct IndexPage { ...@@ -276,7 +299,7 @@ struct IndexPage {
let serializer = new xml.XmlSerializer(bufView); let serializer = new xml.XmlSerializer(bufView);
serializer.setDeclaration(); serializer.setDeclaration();
serializer.startElement("testsuite"); serializer.startElement("testsuite");
serializer.setAttributes("name","ActsPlayerTest"); serializer.setAttributes("name", "ActsPlayerTest");
serializer.setAttributes("time", "*"); serializer.setAttributes("time", "*");
serializer.setAttributes("errors", "0"); serializer.setAttributes("errors", "0");
serializer.setAttributes("disabled", "0"); serializer.setAttributes("disabled", "0");
...@@ -302,42 +325,43 @@ struct IndexPage { ...@@ -302,42 +325,43 @@ struct IndexPage {
let array = new Uint8Array(arrayBuffer); let array = new Uint8Array(arrayBuffer);
let serializerStr = that.decode(array); let serializerStr = that.decode(array);
console.info(xmlPath); console.info(xmlPath);
try{ try {
console.error(TAG,"write xmlPath =" +xmlPath); console.error(TAG, "write xmlPath =" + xmlPath);
var xmlfd = fileIO.openSync(xmlPath, 0o102, 0o666); var xmlfd = fileIO.openSync(xmlPath, 0o102, 0o666);
fileIO.writeSync(xmlfd,serializerStr); fileIO.writeSync(xmlfd, serializerStr);
}catch(err){ } catch (err) {
console.error(TAG,"read xmlPath =" + xmlPath + "error:" + err); console.error(TAG, "read xmlPath =" + xmlPath + "error:" + err);
}finally{ } finally {
fileIO.closeSync(xmlfd); fileIO.closeSync(xmlfd);
} }
return; return;
} }
} }
} }
function filewrite(name1,results,titles){
function filewrite(name1, results, titles) {
let fd = fileio.openSync(txtPath, 0o100 | 0o2002, 0o664); let fd = fileio.openSync(txtPath, 0o100 | 0o2002, 0o664);
let buf = new ArrayBuffer(4096); let buf = new ArrayBuffer(4096);
let RD = fileio.readSync(fd,buf); let RD = fileio.readSync(fd, buf);
console.info("RRRRRRRRRRd"+RD); console.info("RRRRRRRRRRd" + RD);
let report = String.fromCharCode.apply(null,new Uint8Array(buf)); let report = String.fromCharCode.apply(null, new Uint8Array(buf));
let WriteTitle = (titles).toString(); let WriteTitle = (titles).toString();
let WriteResult = (results).toString(); let WriteResult = (results).toString();
let number = WriteTitle.length + WriteResult.length + 2; let number = WriteTitle.length + WriteResult.length + 2;
let Index = report.indexOf(WriteTitle); let Index = report.indexOf(WriteTitle);
let Log = (titles+";"+results+";").toString(); let Log = (titles + ";" + results + ";").toString();
if (Index == -1){ if (Index == -1) {
fileio.writeSync(fd,Log); fileio.writeSync(fd, Log);
} }
else if (Index != -1){ else if (Index != -1) {
let key = report.substring(Index,Index+number); let key = report.substring(Index, Index + number);
let FD = fileio.openSync(txtPath, 0o102, 0o666); let FD = fileio.openSync(txtPath, 0o102, 0o666);
report = report.replace(key,Log); report = report.replace(key, Log);
let buffer = new ArrayBuffer(4096); let buffer = new ArrayBuffer(4096);
let rd = fileio.readSync(FD,buffer); let rd = fileio.readSync(FD, buffer);
let Report = report.substring(0,rd); let Report = report.substring(0, rd);
fileio.closeSync(FD); fileio.closeSync(FD);
let Fd = fileio.openSync(txtPath, 0o102, 0o666); let Fd = fileio.openSync(txtPath, 0o102, 0o666);
fileio.writeSync(Fd,Report); fileio.writeSync(Fd, Report);
} }
} }
\ No newline at end of file
...@@ -20,7 +20,7 @@ import fileIO from '@ohos.fileio'; ...@@ -20,7 +20,7 @@ import fileIO from '@ohos.fileio';
import util from '@ohos.util'; import util from '@ohos.util';
import DateTimeUtil from './model/DateTimeUtil'; import DateTimeUtil from './model/DateTimeUtil';
import data_preferences from '@ohos.data.preferences'; import data_preferences from '@ohos.data.preferences';
import FlushData from '../pages/model/FlushData' import FlushData from '../pages/model/FlushData';
const TAG = 'ParseXML'; const TAG = 'ParseXML';
let path=globalThis.dir; let path=globalThis.dir;
...@@ -34,6 +34,8 @@ let ArkUIColorBackPath = path + '/ArkUIColorBack.txt'; ...@@ -34,6 +34,8 @@ let ArkUIColorBackPath = path + '/ArkUIColorBack.txt';
let AudioColorBackPath = path + '/AudioColorBack.txt'; let AudioColorBackPath = path + '/AudioColorBack.txt';
let CameraColorBackPath = path + '/CameraColorBack.txt'; let CameraColorBackPath = path + '/CameraColorBack.txt';
let PlayerColorBackPath = path + '/PlayerColorBack.txt'; let PlayerColorBackPath = path + '/PlayerColorBack.txt';
let PlayerAudioColorBackPath = path4 + '/PlayerAudioColorBack.txt';
let PlayerVideoColorBackPath = path4 + '/PlayerVideoColorBack.txt';
let ExperienceColorBackPath = path + '/ExperienceColorBack.txt'; let ExperienceColorBackPath = path + '/ExperienceColorBack.txt';
fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664); fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664); fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664);
...@@ -48,6 +50,8 @@ let path11 = path1 + '/ArkUIReport.txt'; ...@@ -48,6 +50,8 @@ let path11 = path1 + '/ArkUIReport.txt';
let path22 = path2 + '/AudioReport.txt'; let path22 = path2 + '/AudioReport.txt';
let path33 = path3 + '/CameraReport.txt'; let path33 = path3 + '/CameraReport.txt';
let path44 = path4 + '/PlayerReport.txt'; let path44 = path4 + '/PlayerReport.txt';
let PlayerAudioTxtPath = path4 + '/PlayerAudioReport.txt';
let PlayerVideoTxtPath = path4 + '/PlayerVideoReport.txt';
let path55 = path5 + '/ExperienceReport.txt'; let path55 = path5 + '/ExperienceReport.txt';
@Entry @Entry
...@@ -97,6 +101,10 @@ struct IndexPage { ...@@ -97,6 +101,10 @@ struct IndexPage {
fileio.openSync(path22, 0o100 | 0o2002, 0o664); fileio.openSync(path22, 0o100 | 0o2002, 0o664);
fileio.openSync(path33, 0o100 | 0o2002, 0o664); fileio.openSync(path33, 0o100 | 0o2002, 0o664);
fileio.openSync(path44, 0o100 | 0o2002, 0o664); fileio.openSync(path44, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerAudioColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerVideoColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerAudioTxtPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerVideoTxtPath, 0o100 | 0o2002, 0o664);
fileio.openSync(path55, 0o100 | 0o2002, 0o664); fileio.openSync(path55, 0o100 | 0o2002, 0o664);
} }
build(){ build(){
...@@ -194,11 +202,15 @@ struct IndexPage { ...@@ -194,11 +202,15 @@ struct IndexPage {
fileio.unlinkSync(path22); fileio.unlinkSync(path22);
fileio.unlinkSync(path33); fileio.unlinkSync(path33);
fileio.unlinkSync(path44); fileio.unlinkSync(path44);
fileio.unlinkSync(PlayerAudioTxtPath);
fileio.unlinkSync(PlayerVideoTxtPath);
fileio.unlinkSync(path55); fileio.unlinkSync(path55);
fileio.unlinkSync(ArkUIColorBackPath); fileio.unlinkSync(ArkUIColorBackPath);
fileio.unlinkSync(AudioColorBackPath); fileio.unlinkSync(AudioColorBackPath);
fileio.unlinkSync(CameraColorBackPath); fileio.unlinkSync(CameraColorBackPath);
fileio.unlinkSync(PlayerColorBackPath); fileio.unlinkSync(PlayerColorBackPath);
fileio.unlinkSync(PlayerAudioColorBackPath);
fileio.unlinkSync(PlayerVideoColorBackPath);
fileio.unlinkSync(ExperienceColorBackPath); fileio.unlinkSync(ExperienceColorBackPath);
fileio.rmdirSync(picturePath); fileio.rmdirSync(picturePath);
fileio.mkdirSync(picturePath); fileio.mkdirSync(picturePath);
...@@ -208,17 +220,23 @@ struct IndexPage { ...@@ -208,17 +220,23 @@ struct IndexPage {
fileio.openSync(path22, 0o100 | 0o2002, 0o664); fileio.openSync(path22, 0o100 | 0o2002, 0o664);
fileio.openSync(path33, 0o100 | 0o2002, 0o664); fileio.openSync(path33, 0o100 | 0o2002, 0o664);
fileio.openSync(path44, 0o100 | 0o2002, 0o664); fileio.openSync(path44, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerAudioTxtPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerVideoTxtPath, 0o100 | 0o2002, 0o664);
fileio.openSync(path55, 0o100 | 0o2002, 0o664); fileio.openSync(path55, 0o100 | 0o2002, 0o664);
fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664); fileio.openSync(ArkUIColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664); fileio.openSync(AudioColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(CameraColorBackPath, 0o100 | 0o2002, 0o664); fileio.openSync(CameraColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerColorBackPath, 0o100 | 0o2002, 0o664); fileio.openSync(PlayerColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerAudioColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(PlayerVideoColorBackPath, 0o100 | 0o2002, 0o664);
fileio.openSync(ExperienceColorBackPath, 0o100 | 0o2002, 0o664); fileio.openSync(ExperienceColorBackPath, 0o100 | 0o2002, 0o664);
FlushData.ResetArkUI(); FlushData.ResetArkUI();
FlushData.ResetAudio(); FlushData.ResetAudio();
FlushData.ResetCamera(); FlushData.ResetCamera();
FlushData.ResetPlayer(); FlushData.ResetPlayer();
FlushData.ResetExperience(); FlushData.ResetExperience();
FlushData.ResetPlayerAudio();
FlushData.ResetPlayerVideo();
} }
SaveXml() { SaveXml() {
let dateTimeUtil = new DateTimeUtil(); let dateTimeUtil = new DateTimeUtil();
......
...@@ -136,4 +136,52 @@ export default class FlushData{ ...@@ -136,4 +136,52 @@ export default class FlushData{
console.info("Succeeded in flushing."); console.info("Succeeded in flushing.");
}); });
} }
static ResetPlayerAudio = async ()=>{
let Test = null;
let context =null;
context = globalThis.getContext();
let preferences;
let promise = data_preferences.getPreferences(context,'mystore');
await promise.then((object) => {
preferences = object;
});
promise = preferences.get('PlayerAudio', 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'PlayerAudio'. Data: " + data);
});
promise = preferences.put('PlayerAudio', 0);
promise.then(() => {
console.info("Succeeded in putting value of 'PlayerAudio'.");
});
promise = preferences.flush();
promise.then(() => {
console.info("Succeeded in flushing.");
});
}
static ResetPlayerVideo = async ()=>{
let Test = null;
let context =null;
context = globalThis.getContext();
let preferences;
let promise = data_preferences.getPreferences(context,'mystore');
await promise.then((object) => {
preferences = object;
});
promise = preferences.get('PlayerVideo', 0);
await promise.then((data) => {
Test = data;
console.info("Succeeded in getting value of 'PlayerVideo'. Data: " + data);
});
promise = preferences.put('PlayerVideo', 0);
promise.then(() => {
console.info("Succeeded in putting value of 'PlayerVideo'.");
});
promise = preferences.flush();
promise.then(() => {
console.info("Succeeded in flushing.");
});
}
} }
\ No newline at end of file
...@@ -37,9 +37,9 @@ export default class MediaUtils { ...@@ -37,9 +37,9 @@ export default class MediaUtils {
Logger.info(this.tag, `displayName = ${displayName},mediaType = ${mediaType}`) Logger.info(this.tag, `displayName = ${displayName},mediaType = ${mediaType}`)
let publicPath = await this.mediaTest.getPublicDirectory(info.directory) let publicPath = await this.mediaTest.getPublicDirectory(info.directory)
Logger.info(this.tag, `publicPath = ${publicPath}`) Logger.info(this.tag, `publicPath = ${publicPath}`)
try{ try {
return await this.mediaTest.createAsset(mediaType, displayName, publicPath) return await this.mediaTest.createAsset(mediaType, displayName, publicPath)
}catch(err){ } catch (err) {
Logger.info(this.tag, `createAsset err ` + JSON.stringify(err)) Logger.info(this.tag, `createAsset err ` + JSON.stringify(err))
} }
...@@ -77,9 +77,26 @@ export default class MediaUtils { ...@@ -77,9 +77,26 @@ export default class MediaUtils {
} }
} }
async getFileAssetsAlbum(path){
let fileKeyObj = mediaLibrary.FileKey
// ALBUM_NAME
let fetchOp = {
selections: `${fileKeyObj.RELATIVE_PATH}=?`,
selectionArgs: [`${path}`],
}
const fetchFileResult = await this.mediaTest.getFileAssets(fetchOp)
Logger.info(this.tag, `getFileAssetsAlbum,fetchFileResult.count = ${fetchFileResult.getCount()}`)
let fileAssets:Array<mediaLibrary.FileAsset> = []
if (fetchFileResult.getCount() > 0) {
fileAssets = await fetchFileResult.getAllObject()
}
return fileAssets
}
async getFileAssetsFromType(mediaType: number) { async getFileAssetsFromType(mediaType: number) {
Logger.info(this.tag, `getFileAssetsFromType,mediaType = ${mediaType}`) Logger.info(this.tag, `getFileAssetsFromType,mediaType = ${mediaType}`)
let fileKeyObj = mediaLibrary.FileKey let fileKeyObj = mediaLibrary.FileKey
// ALBUM_NAME
let fetchOp = { let fetchOp = {
selections: `${fileKeyObj.MEDIA_TYPE}=?`, selections: `${fileKeyObj.MEDIA_TYPE}=?`,
selectionArgs: [`${mediaType}`], selectionArgs: [`${mediaType}`],
...@@ -97,10 +114,10 @@ export default class MediaUtils { ...@@ -97,10 +114,10 @@ export default class MediaUtils {
Logger.info(this.tag, 'getAlbums begin') Logger.info(this.tag, 'getAlbums begin')
let albums = [] let albums = []
const [ files, images, videos, audios ] = await Promise.all([ const [ files, images, videos, audios ] = await Promise.all([
this.getFileAssetsFromType(mediaLibrary.MediaType.FILE), this.getFileAssetsFromType(mediaLibrary.MediaType.FILE),
this.getFileAssetsFromType(mediaLibrary.MediaType.IMAGE), this.getFileAssetsFromType(mediaLibrary.MediaType.IMAGE),
this.getFileAssetsFromType(mediaLibrary.MediaType.VIDEO), this.getFileAssetsFromType(mediaLibrary.MediaType.VIDEO),
this.getFileAssetsFromType(mediaLibrary.MediaType.AUDIO) this.getFileAssetsFromType(mediaLibrary.MediaType.AUDIO)
]) ])
albums.push({ albums.push({
albumName: 'Documents', count: files.length, mediaType: mediaLibrary.MediaType.FILE albumName: 'Documents', count: files.length, mediaType: mediaLibrary.MediaType.FILE
...@@ -120,6 +137,7 @@ export default class MediaUtils { ...@@ -120,6 +137,7 @@ export default class MediaUtils {
deleteFile(media: any) { deleteFile(media: any) {
let uri = media.uri let uri = media.uri
Logger.info(this.tag, `deleteFile,uri = ${uri}`) Logger.info(this.tag, `deleteFile,uri = ${uri}`)
// @ts-ignore
return this.mediaTest.deleteAsset(uri) return this.mediaTest.deleteAsset(uri)
} }
......
...@@ -39,8 +39,6 @@ ...@@ -39,8 +39,6 @@
"pages/Audio/AudioOutputRoutingTypeC", "pages/Audio/AudioOutputRoutingTypeC",
"pages/Audio/AudioOutputRoutingBT", "pages/Audio/AudioOutputRoutingBT",
"pages/Player/Player_index", "pages/Player/Player_index",
"pages/Player/PlayAudio",
"pages/Player/PlayVideo",
"pages/Experience/Experience_index", "pages/Experience/Experience_index",
"pages/Experience/PhotoFps", "pages/Experience/PhotoFps",
"pages/Experience/DeskFps", "pages/Experience/DeskFps",
...@@ -59,6 +57,10 @@ ...@@ -59,6 +57,10 @@
"pages/Experience/StartBackgroundTask", "pages/Experience/StartBackgroundTask",
"pages/Experience/StartNotification", "pages/Experience/StartNotification",
"pages/Experience/ScrollPhotosList", "pages/Experience/ScrollPhotosList",
"pages/Experience/KeyboardInputTest" "pages/Experience/KeyboardInputTest",
"pages/Player/PlayAudio",
"pages/Player/PlayVideo",
"pages/Player/PlayAudioList",
"pages/Player/PlayVideoList"
] ]
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册