HarmonyOS 拍摄录制的动画效果

HarmonyOS
2024-12-20 16:48:03
浏览
收藏 0
回答 1
待解决
回答 1
按赞同
/
按时间
Heiang
import animator, { AnimatorResult } from '@ohos.animator';

@Entry
@Component
struct Page240522161537042 {
  @State progressValue: number = 0
  private animationPlayState: boolean = false
  private progressAnimator: AnimatorResult | undefined = undefined
  create() {
    let _this = this
    this.progressAnimator = animator.create({
      duration: 60000,
      easing: "linear",
      delay: 0,
      fill: "forwards",
      direction: "normal",
      iterations: 1,
      begin: 0,
      end: 60
    })

    this.progressAnimator.onFinish = () => {
      console.info('backAnimator onfinish')
    }
    this.progressAnimator.onRepeat = () => {
      console.info('backAnimator repeat')
    }
    this.progressAnimator.onCancel = () => {
      console.info('backAnimator cancel')
    }
    this.progressAnimator.onFrame = (value: number) => {
      _this.progressValue = value
    }
  }

  aboutToDisappear() {
    // 由于backAnimator在onframe中引用了this, this中保存了backAnimator,
    // 在自定义组件消失时应该将保存在组件中的backAnimator置空,避免内存泄漏
    this.progressAnimator = undefined;
  }

  build() {
    Column({ space: 15 }) {
      Text(`00:${parseInt(this.progressValue + "")}/01:00`)
      Stack() {
        Progress({ value: this.progressValue, total: 60, type: ProgressType.Ring })
          .width(60)
          .style({ strokeWidth: 5 })
          .color(Color.Red)
          .backgroundColor(Color.White)
          .onAppear(() => {
            this.create()
          })

        Row().width(30).height(30).borderRadius(15).backgroundColor("#E3C8FA")
        Row().width(10).height(10).borderRadius(3).backgroundColor(Color.Red)
      }.onClick(() => {
        this.animationPlayState ? this.progressAnimator?.pause() : this.progressAnimator?.play()

        this.animationPlayState = !this.animationPlayState
      })
    }.width('100%').padding({ top: 5 }).alignItems(HorizontalAlign.Center).backgroundColor(Color.Gray)
  }
}
分享
微博
QQ
微信
回复
2024-12-20 19:41:00
相关问题
HarmonyOS List动画效果
998浏览 • 1回复 待解决
HarmonyOS 动画效果+手势
958浏览 • 1回复 待解决
HarmonyOS 列表动画效果
1184浏览 • 1回复 待解决
HarmonyOS 动画效果实现
1464浏览 • 1回复 待解决
HarmonyOS 旋转动画效果
1048浏览 • 1回复 待解决
HarmonyOS .scale没有动画效果
828浏览 • 1回复 待解决
前后双摄录像怎样解决
8020浏览 • 2回复 待解决
HarmonyOS clipShape 动画效果实现
1218浏览 • 0回复 待解决
属性动画如何实现宽高动画效果
3238浏览 • 1回复 待解决
如何实现list折叠动画效果
1747浏览 • 1回复 待解决
如何实现动画转场效果
2144浏览 • 1回复 待解决
HarmonyOS grid拖拽和增删动画效果
1020浏览 • 1回复 待解决
HarmonyOS 实现按钮长按动画效果
1453浏览 • 1回复 待解决
求助动画效果问题有懂吗?
5113浏览 • 1回复 待解决
文字动画效果如何实现
3870浏览 • 0回复 待解决
Tabs 出现/消失转场动画效果
1312浏览 • 1回复 待解决
panGesture结合动画实现fling效果
2011浏览 • 1回复 待解决