Showing
1 changed file
with
15 additions
and
7 deletions
| @@ -18,6 +18,7 @@ export struct PlayerFullScreenView { | @@ -18,6 +18,7 @@ export struct PlayerFullScreenView { | ||
| 18 | @State videoDuration: number = this.contentDetailData?.videoInfo?.[0]?.videoDuration || 1 | 18 | @State videoDuration: number = this.contentDetailData?.videoInfo?.[0]?.videoDuration || 1 |
| 19 | @State showOperator: boolean = true | 19 | @State showOperator: boolean = true |
| 20 | private timer: number = -1 | 20 | private timer: number = -1 |
| 21 | + private debounceTimer: number = -1 | ||
| 21 | @State upProVal: string = '' | 22 | @State upProVal: string = '' |
| 22 | @State duration: string = DateTimeUtils.secondToTime(this.videoDuration) | 23 | @State duration: string = DateTimeUtils.secondToTime(this.videoDuration) |
| 23 | @State startX: number = 0 | 24 | @State startX: number = 0 |
| @@ -80,6 +81,13 @@ export struct PlayerFullScreenView { | @@ -80,6 +81,13 @@ export struct PlayerFullScreenView { | ||
| 80 | }, 5000) | 81 | }, 5000) |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 84 | + debounce(func: () => void, wait: number) { | ||
| 85 | + if (this.debounceTimer) { | ||
| 86 | + clearTimeout(this.debounceTimer); | ||
| 87 | + } | ||
| 88 | + this.debounceTimer = setTimeout(func, wait); | ||
| 89 | + } | ||
| 90 | + | ||
| 83 | build() { | 91 | build() { |
| 84 | Stack({ alignContent: Alignment.Center }) { | 92 | Stack({ alignContent: Alignment.Center }) { |
| 85 | Row() { | 93 | Row() { |
| @@ -121,7 +129,7 @@ export struct PlayerFullScreenView { | @@ -121,7 +129,7 @@ export struct PlayerFullScreenView { | ||
| 121 | .gesture( | 129 | .gesture( |
| 122 | PanGesture(this.panOptionBright) | 130 | PanGesture(this.panOptionBright) |
| 123 | .onActionStart((event?: GestureEvent) => { | 131 | .onActionStart((event?: GestureEvent) => { |
| 124 | - console.log(TAG, 'onActionEnd this.panOptionBright') | 132 | + // console.log(TAG, 'onActionEnd this.panOptionBright') |
| 125 | this.isShowBright = true | 133 | this.isShowBright = true |
| 126 | this.playerController?.onBrightActionStart(event!); | 134 | this.playerController?.onBrightActionStart(event!); |
| 127 | }) | 135 | }) |
| @@ -129,9 +137,9 @@ export struct PlayerFullScreenView { | @@ -129,9 +137,9 @@ export struct PlayerFullScreenView { | ||
| 129 | this.playerController?.onBrightActionUpdate(event!); | 137 | this.playerController?.onBrightActionUpdate(event!); |
| 130 | }) | 138 | }) |
| 131 | .onActionEnd(() => { | 139 | .onActionEnd(() => { |
| 132 | - setTimeout(() => { | ||
| 133 | - this.isShowBright = false | ||
| 134 | - }, 500) | 140 | + this.debounce(() => { |
| 141 | + this.isShowBright = false; | ||
| 142 | + }, 1000); | ||
| 135 | this.playerController?.onActionEnd(); | 143 | this.playerController?.onActionEnd(); |
| 136 | }) | 144 | }) |
| 137 | ) | 145 | ) |
| @@ -154,9 +162,9 @@ export struct PlayerFullScreenView { | @@ -154,9 +162,9 @@ export struct PlayerFullScreenView { | ||
| 154 | this.playerController?.onVolumeActionUpdate(event!); | 162 | this.playerController?.onVolumeActionUpdate(event!); |
| 155 | }) | 163 | }) |
| 156 | .onActionEnd(() => { | 164 | .onActionEnd(() => { |
| 157 | - setTimeout(() => { | ||
| 158 | - this.isShowVolume = false | ||
| 159 | - }, 500) | 165 | + this.debounce(() => { |
| 166 | + this.isShowVolume = false; | ||
| 167 | + }, 1000); | ||
| 160 | this.playerController?.onActionEnd(); | 168 | this.playerController?.onActionEnd(); |
| 161 | }) | 169 | }) |
| 162 | ) | 170 | ) |
-
Please register or login to post a comment