refactor: ScreenRecord

This commit is contained in:
lilong.129
2025-02-11 16:06:26 +08:00
parent 040e2fa06f
commit 804a2cd90f
8 changed files with 13 additions and 26 deletions

View File

@@ -895,17 +895,10 @@ var androidActivities = map[string]map[string][]string{
// TODO: SPH, XHS
}
func (ad *ADBDriver) ScreenRecord(folderPath string, duration time.Duration) (videoPath string, err error) {
// 获取当前时间戳
func (ad *ADBDriver) ScreenRecord(duration time.Duration) (videoPath string, err error) {
timestamp := time.Now().Format("20060102_150405") + fmt.Sprintf("_%03d", time.Now().UnixNano()/1e6%1000)
// 创建文件名
fileName := fmt.Sprintf("%s/%s.mp4", folderPath, timestamp)
err = os.MkdirAll(folderPath, os.ModePerm)
if err != nil {
log.Error().Err(err).Msg("Error creating directory")
}
fileName := filepath.Join(config.ScreenShotsPath, fmt.Sprintf("%s.mp4", timestamp))
// 创建一个文件
file, err := os.Create(fileName)
if err != nil {
log.Error().Err(err)