dev #63
@ -5,7 +5,7 @@ import { dateFormat } from '../utils/tools'
 | 
				
			|||||||
import FileUtil from '../../common/utils/File'
 | 
					import FileUtil from '../../common/utils/File'
 | 
				
			||||||
import AccountTable from '../../common/database/tables/AccountTable'
 | 
					import AccountTable from '../../common/database/tables/AccountTable'
 | 
				
			||||||
import MA_SYSSET from '../../common/constants/MA_SYSSET'
 | 
					import MA_SYSSET from '../../common/constants/MA_SYSSET'
 | 
				
			||||||
import { takePhoto } from '../../common/service/videoService'
 | 
					import { takePhoto,deleteAllFileByPiC } from '../../common/service/videoService'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  delSyncTable,
 | 
					  delSyncTable,
 | 
				
			||||||
@ -46,6 +46,7 @@ export async function deleteAllFIleLog(path){
 | 
				
			|||||||
    "recursion": false,
 | 
					    "recursion": false,
 | 
				
			||||||
    "listNum": 0,
 | 
					    "listNum": 0,
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let filenames = fs.listFileSync(path, options);
 | 
					  let filenames = fs.listFileSync(path, options);
 | 
				
			||||||
  console.info("listFile succeed",JSON.stringify(filenames));
 | 
					  console.info("listFile succeed",JSON.stringify(filenames));
 | 
				
			||||||
  for (let i = 0; i < filenames.length; i++) {
 | 
					  for (let i = 0; i < filenames.length; i++) {
 | 
				
			||||||
@ -64,6 +65,30 @@ export async function deleteAllFIleLog(path){
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					export async function delHilgo(){
 | 
				
			||||||
 | 
					  const fileUtil = new FileUtil(globalThis.context)
 | 
				
			||||||
 | 
					  const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/hilogTime.txt');
 | 
				
			||||||
 | 
					  if(data === '' || data === undefined){
 | 
				
			||||||
 | 
					    const folderPath = await fileUtil.initFolder(`/config`);
 | 
				
			||||||
 | 
					    fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(1))
 | 
				
			||||||
 | 
					  }else{
 | 
				
			||||||
 | 
					    if(Number(data)<7){
 | 
				
			||||||
 | 
					      let num=Number(data)+1
 | 
				
			||||||
 | 
					      fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(num))
 | 
				
			||||||
 | 
					    }else{
 | 
				
			||||||
 | 
					      let num=Number(data)+1
 | 
				
			||||||
 | 
					      fileUtil.addFile(`${folderPath}/hilogTime.txt`, JSON.stringify(1))
 | 
				
			||||||
 | 
					      fs.rmdir('/data/log/hilog', (err) => {
 | 
				
			||||||
 | 
					        if (err) {
 | 
				
			||||||
 | 
					          console.error("rmdir failed with error message: " + err.message + ", error code: " + err.code);
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					          console.info("rmdir succeed");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					      });
 | 
				
			||||||
 | 
					      deleteAllFileByPiC('jt',1)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
function isSevenDaysAgo(date) {
 | 
					function isSevenDaysAgo(date) {
 | 
				
			||||||
  const today = new Date(); // 当前日期
 | 
					  const today = new Date(); // 当前日期
 | 
				
			||||||
  const target = new Date(date); // 需要判断的日期
 | 
					  const target = new Date(date); // 需要判断的日期
 | 
				
			||||||
 | 
				
			|||||||
@ -5,45 +5,55 @@ import fs from '@ohos.file.fs'
 | 
				
			|||||||
// @ts-ignore
 | 
					// @ts-ignore
 | 
				
			||||||
import photoAccessHelper from '@ohos.file.photoAccessHelper'
 | 
					import photoAccessHelper from '@ohos.file.photoAccessHelper'
 | 
				
			||||||
import dataSharePredicates from '@ohos.data.dataSharePredicates'
 | 
					import dataSharePredicates from '@ohos.data.dataSharePredicates'
 | 
				
			||||||
import { getCurrentTime } from '../utils/tools'
 | 
					import { dateFormat, getCurrentTime, isSevenDaysAgo } from '../utils/tools'
 | 
				
			||||||
// import rtsp_server from '@ohos.rtsprecord';
 | 
					// import rtsp_server from '@ohos.rtsprecord';
 | 
				
			||||||
import record from '@ohos.rtsprecord';
 | 
					import record from '@ohos.rtsprecord';
 | 
				
			||||||
import { FileHelper } from './FileHelper';
 | 
					import { FileHelper } from './FileHelper';
 | 
				
			||||||
 | 
					import FileUtil from '../utils/File';
 | 
				
			||||||
 | 
					import { GlobalConfig } from '../../config';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const rtsp_server = record.createServer();
 | 
					const rtsp_server = record.createServer();
 | 
				
			||||||
//开始录屏
 | 
					//开始录屏
 | 
				
			||||||
const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI,
 | 
					const FILE_ASSET_FETCH_COLUMNS = [photoAccessHelper.PhotoKeys.URI,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.PHOTO_TYPE,
 | 
					  photoAccessHelper.PhotoKeys.PHOTO_TYPE,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.DISPLAY_NAME,
 | 
					  photoAccessHelper.PhotoKeys.DISPLAY_NAME,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.SIZE,
 | 
					  photoAccessHelper.PhotoKeys.SIZE,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.DATE_ADDED,
 | 
					  photoAccessHelper.PhotoKeys.DATE_ADDED,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.DATE_MODIFIED,
 | 
					  photoAccessHelper.PhotoKeys.DATE_MODIFIED,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.DURATION,
 | 
					  photoAccessHelper.PhotoKeys.DURATION,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.WIDTH,
 | 
					  photoAccessHelper.PhotoKeys.WIDTH,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.HEIGHT,
 | 
					  photoAccessHelper.PhotoKeys.HEIGHT,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.DATE_TAKEN,
 | 
					  photoAccessHelper.PhotoKeys.DATE_TAKEN,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.ORIENTATION,
 | 
					  photoAccessHelper.PhotoKeys.ORIENTATION,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.FAVORITE,
 | 
					  photoAccessHelper.PhotoKeys.FAVORITE,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.TITLE,
 | 
					  photoAccessHelper.PhotoKeys.TITLE,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.POSITION,
 | 
					  photoAccessHelper.PhotoKeys.POSITION,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.DATE_TRASHED,
 | 
					  photoAccessHelper.PhotoKeys.DATE_TRASHED,
 | 
				
			||||||
photoAccessHelper.PhotoKeys.HIDDEN];
 | 
					  photoAccessHelper.PhotoKeys.HIDDEN];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// const rtsp_server = record.createServer();
 | 
					// const rtsp_server = record.createServer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function startRecordVideo(param, td, context, dir) {
 | 
					export async function startRecordVideo(param, td, context, dir, path?) {
 | 
				
			||||||
  return new Promise((reslove, reject) => {
 | 
					  return new Promise(async (reslove, reject) => {
 | 
				
			||||||
 | 
					    // const fileUtil = new FileUtil(globalThis.context)
 | 
				
			||||||
 | 
					    // const date=dateFormat(new Date).split(' ')[0]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // const folderPath = await fileUtil.initFolder(`/PLC/${date}/${dir}`);
 | 
				
			||||||
    var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${td}/main/av_stream`;
 | 
					    var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${td}/main/av_stream`;
 | 
				
			||||||
    if (rtsp_server != null) {
 | 
					    if (rtsp_server != null) {
 | 
				
			||||||
      console.log(`Rtsprecord startRecordVideo begin,video_uri`, video_uri);
 | 
					      console.log(`Rtsprecord startRecordVideo begin,video_uri`, video_uri);
 | 
				
			||||||
      const num = Math.floor(Math.random() * 10000)
 | 
					      const num = Math.floor(Math.random() * 10000)
 | 
				
			||||||
      const fileName = `movie_record${num}.mp4`
 | 
					      let fileName
 | 
				
			||||||
 | 
					      if (!path) {
 | 
				
			||||||
 | 
					        fileName = `movie_record${num}.mp4`
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        fileName = `${path}.mp4`
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      // @ts-ignore
 | 
					      // @ts-ignore
 | 
				
			||||||
      var recordResult = rtsp_server.startRecordVideo(context, video_uri, fileName, dir);
 | 
					      var recordResult = rtsp_server.startRecordVideo(context, video_uri, fileName, dir);
 | 
				
			||||||
      const handleId = recordResult.dataInt;
 | 
					      const handleId = recordResult.dataInt;
 | 
				
			||||||
      console.log(`Rtsprecord startRecordVideo begin,handleId`, handleId);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      reslove(handleId)
 | 
					      reslove(handleId)
 | 
				
			||||||
      console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt);
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
      console.log(`Rtsprecord startRecordVideo rtsp_server isnull`);
 | 
					      console.log(`Rtsprecord startRecordVideo rtsp_server isnull`);
 | 
				
			||||||
@ -55,21 +65,93 @@ export async function startRecordVideo(param, td, context, dir) {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//结束录屏
 | 
					//结束录屏
 | 
				
			||||||
export async function endRecordVideo(record_handle) {
 | 
					export async function endRecordVideo(record_handleObj) {
 | 
				
			||||||
  if (rtsp_server != null && record_handle > 0) {
 | 
					  for (let key in record_handleObj) {
 | 
				
			||||||
 | 
					    if (rtsp_server != null && record_handleObj[key] > 0) {
 | 
				
			||||||
      console.log(`Rtsprecord endRecordVideo begin`);
 | 
					      console.log(`Rtsprecord endRecordVideo begin`);
 | 
				
			||||||
      // @ts-ignore
 | 
					      // @ts-ignore
 | 
				
			||||||
    var recordResult = rtsp_server.endRecordVideo(record_handle);
 | 
					      var recordResult = rtsp_server.endRecordVideo(record_handleObj[key]);
 | 
				
			||||||
    console.log(`Rtsprecord startRecordVideo record_handle` + recordResult.dataInt + ` filename:` + recordResult.fileName);
 | 
					      console.log(`Rtsprecord endRecordVideo record_handle` + record_handleObj[key].dataInt + ` filename:` + record_handleObj[key].fileName);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
      console.log(`Rtsprecord endRecordVideo handleId isnull`);
 | 
					      console.log(`Rtsprecord endRecordVideo handleId isnull`);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  // var result = onvifclient.endRecordVideo(record_handle);
 | 
					  }
 | 
				
			||||||
  // fs.closeSync(record_handle);
 | 
					 | 
				
			||||||
  // file_asset.close(record_handle);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export async function saveStartRecordVideo(path) {
 | 
				
			||||||
 | 
					  return new Promise(async (reslove, reject) => {
 | 
				
			||||||
 | 
					    const fileUtil = new FileUtil(globalThis.context)
 | 
				
			||||||
 | 
					    const fileHelper = new FileHelper();
 | 
				
			||||||
 | 
					    const date = dateFormat(new Date).split(' ')[0]
 | 
				
			||||||
 | 
					    fileHelper.createAlbum(date);
 | 
				
			||||||
 | 
					    // const folderPath = await fileUtil.initFolder(`/${path}/${date}`);
 | 
				
			||||||
 | 
					    const data = await fileUtil.readFile(GlobalConfig.comoonfileWriteAddress + '/config/config3.txt');
 | 
				
			||||||
 | 
					    const param = JSON.parse(data)
 | 
				
			||||||
 | 
					    const record_handle = {
 | 
				
			||||||
 | 
					      1: 0,
 | 
				
			||||||
 | 
					      2: 1,
 | 
				
			||||||
 | 
					      3: 2,
 | 
				
			||||||
 | 
					      4: 3
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    for (let i = 1; i <= 4; i++) {
 | 
				
			||||||
 | 
					      if (param['videoRecord'+i]) {
 | 
				
			||||||
 | 
					        console.log('pathpath0',path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        record_handle[i] = await getfilehandleCode(i, param, date, path)
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    reslove(record_handle)
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function getfilehandleCode(td, param, dir, path) {
 | 
				
			||||||
 | 
					  return new Promise(async (reslove, reject) => {
 | 
				
			||||||
 | 
					    console.log('pathpath1',path)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    const record_handle = await startRecordVideo(param, td, globalThis.context, dir, path)
 | 
				
			||||||
 | 
					    // this.rocordHandleObj['rocord_handle'+td] = record_handle
 | 
				
			||||||
 | 
					    reslove(record_handle)
 | 
				
			||||||
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export async function getUserAlbumItemByDisplayName(displayName: string): Promise<photoAccessHelper.Album> {
 | 
				
			||||||
 | 
					  let fetchResult = null
 | 
				
			||||||
 | 
					  let album: photoAccessHelper.Album = null
 | 
				
			||||||
 | 
					  try {
 | 
				
			||||||
 | 
					    console.log('getUserAlbumItemByDisplayName');
 | 
				
			||||||
 | 
					    let predicates = new dataSharePredicates.DataSharePredicates();
 | 
				
			||||||
 | 
					    predicates.equalTo(photoAccessHelper.AlbumKeys.ALBUM_NAME, displayName)
 | 
				
			||||||
 | 
					    let fetchOptions = {
 | 
				
			||||||
 | 
					      fetchColumns: [],
 | 
				
			||||||
 | 
					      predicates: predicates
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    const userFileMgr = photoAccessHelper.getPhotoAccessHelper(globalThis.context);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fetchResult = await userFileMgr.getAlbums(photoAccessHelper.AlbumType.USER, photoAccessHelper.AlbumSubtype.USER_GENERIC, fetchOptions);
 | 
				
			||||||
 | 
					    console.log('get getUserAlbumItemByDisplayName, count: ' + JSON.stringify(fetchResult));
 | 
				
			||||||
 | 
					    if (fetchResult.getCount() > 0) {
 | 
				
			||||||
 | 
					      const albums = await fetchResult.getLastObject();
 | 
				
			||||||
 | 
					      if(isSevenDaysAgo(albums.albumName)){
 | 
				
			||||||
 | 
					        deleteAllFileByPiC(albums.albumName,2)
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      console.log('get getUserAlbumItemByDisplayName album',)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  } catch (err) {
 | 
				
			||||||
 | 
					    console.log('get Album getUserAlbumItemByDisplayName fetchResult failed with err: ' + err);
 | 
				
			||||||
 | 
					  } finally {
 | 
				
			||||||
 | 
					    if (fetchResult != null) {
 | 
				
			||||||
 | 
					      fetchResult.close();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return album;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *拍照
 | 
					 *拍照
 | 
				
			||||||
 * @param param
 | 
					 * @param param
 | 
				
			||||||
@ -77,11 +159,12 @@ export async function endRecordVideo(record_handle) {
 | 
				
			|||||||
 * @param type=0不获取base64
 | 
					 * @param type=0不获取base64
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
interface takePhotoParam {
 | 
					interface takePhotoParam {
 | 
				
			||||||
  name?:string,
 | 
					  name?: string,
 | 
				
			||||||
  base64?:string,
 | 
					  base64?: string,
 | 
				
			||||||
  fileSize?:number,
 | 
					  fileSize?: number,
 | 
				
			||||||
  errorCode?:number
 | 
					  errorCode?: number
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * @param param
 | 
					 * @param param
 | 
				
			||||||
@ -92,32 +175,38 @@ interface  takePhotoParam {
 | 
				
			|||||||
 * @returns
 | 
					 * @returns
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
const fileHelper = new FileHelper();
 | 
					const fileHelper = new FileHelper();
 | 
				
			||||||
export async function takePhoto(param, context,dir,flag=1,callback?) {
 | 
					
 | 
				
			||||||
 | 
					export async function takePhoto(param, context, dir, flag = 1, callback?) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`;
 | 
					  var video_uri = `rtsp://${param.userName}:${param.pwd}@${param.ip}:${param.port}/h264/ch${param.pztd}/main/av_stream`;
 | 
				
			||||||
  // var video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`;
 | 
					  // var video_uri = `rtsp://admin:openharmony1@192.168.1.66:554/Streaming/Channels/3`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const num = Math.floor(Math.random() * 10000)
 | 
					  const num = Math.floor(Math.random() * 10000)
 | 
				
			||||||
  const fileName = `picture_record${num}.jpg`
 | 
					  const fileName = `picture_record${num}.jpg`
 | 
				
			||||||
console.log('baoyihubaoyihu',video_uri,flag)
 | 
					  console.log('baoyihubaoyihu', video_uri, flag)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  console.log(`baoyihu Rtsprecord baohaowen getVideoSnapshot fileName:` + fileName);
 | 
					  console.log(`baoyihu Rtsprecord baohaowen getVideoSnapshot fileName:` + fileName);
 | 
				
			||||||
  // @ts-ignore
 | 
					  // @ts-ignore
 | 
				
			||||||
  // var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, '', dir);
 | 
					  // var snapResult = rtsp_server.getVideoSnapshot(context, video_uri, '', dir);
 | 
				
			||||||
  if(flag==0){
 | 
					  if (flag == 0) {
 | 
				
			||||||
    rtsp_server.detectVideoSnapshotSize(video_uri,fileName,(err,snapResult)=>{
 | 
					    rtsp_server.detectVideoSnapshotSize(video_uri, fileName, (err, snapResult) => {
 | 
				
			||||||
      console.log("baohaowen_detectLoop round end size1:"+snapResult.fileSize);
 | 
					      console.log("baohaowen_detectLoop round end size1:" + snapResult.fileSize);
 | 
				
			||||||
      callback({fileSize:snapResult.fileSize,errorCode:snapResult.errorCode })
 | 
					      callback({ fileSize: snapResult.fileSize, errorCode: snapResult.errorCode })
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else{
 | 
					  else {
 | 
				
			||||||
    console.log('baoyihubaoyihu1',video_uri,flag)
 | 
					    console.log('baoyihubaoyihu1', video_uri, flag)
 | 
				
			||||||
    return new Promise<takePhotoParam>((resolve,reject)=>{
 | 
					    return new Promise<takePhotoParam>((resolve, reject) => {
 | 
				
			||||||
      rtsp_server.getVideoSnapshot(context, video_uri, fileName,dir,true,(err,snapResult)=>{
 | 
					      rtsp_server.getVideoSnapshot(context, video_uri, fileName, dir, true, (err, snapResult) => {
 | 
				
			||||||
        console.log('baoyihubaoyihu',video_uri,flag,JSON.stringify(snapResult))
 | 
					        console.log('baoyihubaoyihu', video_uri, flag, JSON.stringify(snapResult))
 | 
				
			||||||
        console.log('getPhtot',JSON.stringify(snapResult))
 | 
					        console.log('getPhtot', JSON.stringify(snapResult))
 | 
				
			||||||
        resolve({base64: snapResult.dataString,name:snapResult.fileName,fileSize:snapResult.fileSize,errorCode:snapResult.errorCode })
 | 
					        resolve({
 | 
				
			||||||
 | 
					          base64: snapResult.dataString,
 | 
				
			||||||
 | 
					          name: snapResult.fileName,
 | 
				
			||||||
 | 
					          fileSize: snapResult.fileSize,
 | 
				
			||||||
 | 
					          errorCode: snapResult.errorCode
 | 
				
			||||||
 | 
					        })
 | 
				
			||||||
      });
 | 
					      });
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
    console.log('getmyLog02')
 | 
					    console.log('getmyLog02')
 | 
				
			||||||
@ -127,13 +216,14 @@ console.log('baoyihubaoyihu',video_uri,flag)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//type:1 是图片 2是视频
 | 
					//type:1 是图片 2是视频
 | 
				
			||||||
export async function deleteAllFileByPiC(dirName,type=1) {
 | 
					export async function deleteAllFileByPiC(dirName, type = 1) {
 | 
				
			||||||
  // const fileHelper = new FileHelper();
 | 
					  // const fileHelper = new FileHelper();
 | 
				
			||||||
  fileHelper.deleteFileOfAlbum(dirName,type);
 | 
					  fileHelper.deleteFileOfAlbum(dirName, type);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function deleteAllVideos(context,type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise<void> {
 | 
					export async function deleteAllVideos(context, type: photoAccessHelper.AlbumType, subType: photoAccessHelper.AlbumSubtype): Promise<void> {
 | 
				
			||||||
  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
 | 
					  let fetchResult: photoAccessHelper.FetchResult<photoAccessHelper.Album> = null;
 | 
				
			||||||
  try {
 | 
					  try {
 | 
				
			||||||
    const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context);
 | 
					    const userFileMgr = photoAccessHelper.getPhotoAccessHelper(context);
 | 
				
			||||||
 | 
				
			|||||||
@ -93,12 +93,13 @@ export class voiceService {
 | 
				
			|||||||
  // 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例
 | 
					  // 以下为使用资源管理接口获取打包在HAP内的媒体资源文件并通过fdSrc属性进行播放示例
 | 
				
			||||||
  avPlayerFdSrc(name) {
 | 
					  avPlayerFdSrc(name) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    globalThis.context.resourceManager.getRawFd(name, (error, value) => {
 | 
					    globalThis.context.resourceManager.getRawFd(name,async (error, value) => {
 | 
				
			||||||
      if (error != null) {
 | 
					      if (error != null) {
 | 
				
			||||||
        console.log(`jiangsong callback getRawFd failed error code: ${error.code}, message: ${error.message}.`);
 | 
					        console.log(`jiangsong callback getRawFd failed error code: ${error.code}, message: ${error.message}.`);
 | 
				
			||||||
      } else {
 | 
					      } else {
 | 
				
			||||||
        console.log('jiangsongjiangsong',this.avPlayer)
 | 
					        console.log('jiangsongjiangsong',this.avPlayer)
 | 
				
			||||||
        if (this.avPlayer) {
 | 
					        if (this.avPlayer) {
 | 
				
			||||||
 | 
					          await this.avPlayer.reset()
 | 
				
			||||||
          this.avPlayer.fdSrc = value;
 | 
					          this.avPlayer.fdSrc = value;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,18 @@
 | 
				
			|||||||
import systemTime from '@ohos.systemDateTime';
 | 
					import systemTime from '@ohos.systemDateTime';
 | 
				
			||||||
import { expect } from '@ohos/hypium';
 | 
					import { expect } from '@ohos/hypium';
 | 
				
			||||||
import FileUtil from './File';
 | 
					import FileUtil from './File';
 | 
				
			||||||
 | 
					export  function isSevenDaysAgo(date) {
 | 
				
			||||||
 | 
					  const today = new Date(); // 当前日期
 | 
				
			||||||
 | 
					  const target = new Date(date); // 需要判断的日期
 | 
				
			||||||
 | 
					  console.info("listFile succeed1",JSON.stringify(target));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  const diff = today.getTime() - target.getTime(); // 计算两个日期之间的毫秒数差异
 | 
				
			||||||
 | 
					  const diffDays = diff / (1000 * 60 * 60 * 24); // 将毫秒转换为天数
 | 
				
			||||||
 | 
					  console.info("listFile succeed2",JSON.stringify(diffDays));
 | 
				
			||||||
 | 
					  // 如果差异天数正好是7,则原日期是当前日期的前七天
 | 
				
			||||||
 | 
					  console.log('diffDays',diffDays)
 | 
				
			||||||
 | 
					  return diffDays > 7;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
export async function writeLog(path,param){
 | 
					export async function writeLog(path,param){
 | 
				
			||||||
  return
 | 
					  return
 | 
				
			||||||
  const fileUtil = new FileUtil(globalThis.context)
 | 
					  const fileUtil = new FileUtil(globalThis.context)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user