chenjun

fix seek后滑块会回退

@@ -19,10 +19,13 @@ export struct PlayerFullScreenView { @@ -19,10 +19,13 @@ export struct PlayerFullScreenView {
19 private timer: number = -1 19 private timer: number = -1
20 @State upProVal: string = '' 20 @State upProVal: string = ''
21 @State duration: string = DateTimeUtils.secondToTime(this.videoDuration) 21 @State duration: string = DateTimeUtils.secondToTime(this.videoDuration)
22 - @State startX:number = 0  
23 - @State endX:number = 0  
24 - @State panDirection:number = 1 //1左滑 2右滑  
25 - private panDistance:number = 0 22 + @State startX: number = 0
  23 + @State endX: number = 0
  24 + @State panDirection: number = 1 //1左滑 2右滑
  25 + private panDistance: number = 0
  26 + private touchDownX: number = 0
  27 + private touchUpX: number = 0
  28 + @State isTouched: boolean = false
26 29
27 getTitle() { 30 getTitle() {
28 return this.contentDetailData?.newsTitle 31 return this.contentDetailData?.newsTitle
@@ -156,11 +159,14 @@ export struct PlayerFullScreenView { @@ -156,11 +159,14 @@ export struct PlayerFullScreenView {
156 159
157 PlayerProgressFullScreenView({ playerController: this.playerController }).layoutWeight(1) 160 PlayerProgressFullScreenView({ playerController: this.playerController }).layoutWeight(1)
158 .onTouch((event?: TouchEvent) => { 161 .onTouch((event?: TouchEvent) => {
  162 +
159 if (event) { 163 if (event) {
160 if (event.type === TouchType.Down) { 164 if (event.type === TouchType.Down) {
  165 + // console.info(`cj2024 onTouch Down x=${event?.tiltX}`)
161 clearInterval(this.timer) 166 clearInterval(this.timer)
162 } 167 }
163 if (event.type === TouchType.Up) { 168 if (event.type === TouchType.Up) {
  169 + // console.info(`cj2024 onTouch Up x=${event?.tiltX}`)
164 this.restartTimer(); 170 this.restartTimer();
165 } 171 }
166 } 172 }
@@ -202,7 +208,7 @@ export struct PlayerFullScreenView { @@ -202,7 +208,7 @@ export struct PlayerFullScreenView {
202 .margin({ top: 73, bottom: 73 }) 208 .margin({ top: 73, bottom: 73 })
203 // .backgroundColor('#FF0000') 209 // .backgroundColor('#FF0000')
204 .onClick(() => { 210 .onClick(() => {
205 - Logger.warn(`cj2024 onClick showOperator=${this.showOperator}`) 211 + Logger.warn(`cj2024 onClick showOperator=${this.showOperator}`)
206 if (!this.isDragging) { 212 if (!this.isDragging) {
207 if (this.showOperator == false) { 213 if (this.showOperator == false) {
208 this.restartTimer(); 214 this.restartTimer();
@@ -241,7 +247,8 @@ export struct PlayerFullScreenView { @@ -241,7 +247,8 @@ export struct PlayerFullScreenView {
241 this.endX = event.offsetX 247 this.endX = event.offsetX
242 } 248 }
243 this.panDirection = this.endX - this.startX > 0 ? 2 : 1 249 this.panDirection = this.endX - this.startX > 0 ? 2 : 1
244 - Logger.warn(`cj2024 pan end panDirection = ${this.panDirection} this.progressVal = ${this.progressVal} dir=${this.endX - this.startX}`) 250 + Logger.warn(`cj2024 pan end panDirection = ${this.panDirection} this.progressVal = ${this.progressVal} dir=${this.endX -
  251 + this.startX}`)
245 if (Math.abs(this.endX - this.startX) < 100) { 252 if (Math.abs(this.endX - this.startX) < 100) {
246 this.panDistance = 1 253 this.panDistance = 1
247 } else { 254 } else {
@@ -254,7 +261,7 @@ export struct PlayerFullScreenView { @@ -254,7 +261,7 @@ export struct PlayerFullScreenView {
254 this.progressVal = 0 261 this.progressVal = 0
255 } 262 }
256 } else { 263 } else {
257 - if (this.progressVal <100) { 264 + if (this.progressVal < 100) {
258 this.progressVal += this.panDistance 265 this.progressVal += this.panDistance
259 } else { 266 } else {
260 this.progressVal = 100 267 this.progressVal = 100
@@ -285,7 +292,11 @@ export struct PlayerFullScreenView { @@ -285,7 +292,11 @@ export struct PlayerFullScreenView {
285 .width('100%') 292 .width('100%')
286 .height('100%') 293 .height('100%')
287 .onChange((value: number, mode: SliderChangeMode) => { 294 .onChange((value: number, mode: SliderChangeMode) => {
  295 + // if (this.isTouched) {
  296 + // return
  297 + // }
288 this.progressVal = value 298 this.progressVal = value
  299 + // console.log('cj2024 onChange slider value:', value)
289 if (mode === SliderChangeMode.Moving) { 300 if (mode === SliderChangeMode.Moving) {
290 this.isDragging = true 301 this.isDragging = true
291 } 302 }
@@ -293,20 +304,33 @@ export struct PlayerFullScreenView { @@ -293,20 +304,33 @@ export struct PlayerFullScreenView {
293 this.isDragging = false 304 this.isDragging = false
294 this.playerController?.setSeekTime(this.progressVal, SliderChangeMode.End); 305 this.playerController?.setSeekTime(this.progressVal, SliderChangeMode.End);
295 } 306 }
296 -  
297 - console.log('Transparent slider value:', value)  
298 }) 307 })
299 }.margin({ top: 73, bottom: 73 }) 308 }.margin({ top: 73, bottom: 73 })
300 .onTouch((event?: TouchEvent) => { 309 .onTouch((event?: TouchEvent) => {
  310 + // console.log(`cj2024 onTouch isDragging = ${this.isDragging}`)
  311 + if (this.isDragging) {
  312 + return
  313 + }
301 if (event) { 314 if (event) {
302 if (event.type === TouchType.Down) { 315 if (event.type === TouchType.Down) {
  316 + // console.info(`cj2024 onTouch Down x=${event?.touches[0].x}`)
  317 + if (event?.touches.length > 0) {
  318 + this.touchDownX = event?.touches[0].x
  319 + }
303 clearInterval(this.timer) 320 clearInterval(this.timer)
304 } 321 }
305 if (event.type === TouchType.Up) { 322 if (event.type === TouchType.Up) {
  323 + // console.info(`cj2024 onTouch Up x=${event?.touches[0].x}`)
  324 + if (event?.touches.length > 0) {
  325 + this.touchUpX = event?.touches[0].x
  326 + this.isTouched = this.touchUpX == this.touchDownX ? true : false
  327 + }
306 if (this.showOperator == false) { 328 if (this.showOperator == false) {
307 this.restartTimer(); 329 this.restartTimer();
308 } else { 330 } else {
309 - this.showOperator = false 331 + if (this.isTouched) {
  332 + this.showOperator = false
  333 + }
310 } 334 }
311 } 335 }
312 } 336 }
@@ -341,9 +341,12 @@ export class WDPlayerController { @@ -341,9 +341,12 @@ export class WDPlayerController {
341 // 100 / 1000)); 341 // 100 / 1000));
342 } 342 }
343 if (mode === SliderChangeMode.End) { 343 if (mode === SliderChangeMode.End) {
  344 + // Logger.warn(`cj2024 seekTime = ${value}`)
  345 + // Logger.warn(`cj2024 duration = ${this.duration}`)
344 this.seekTime = Math.floor(value * this.duration / 100); 346 this.seekTime = Math.floor(value * this.duration / 100);
  347 + // Logger.warn(`cj2024 seekTime = ${this.seekTime}`)
345 this.currentPlayTime = this.seekTime 348 this.currentPlayTime = this.seekTime
346 - this.avPlayer?.seek(this.seekTime); 349 + this.avPlayer?.seek(this.seekTime,media.SeekMode.SEEK_CLOSEST);
347 } 350 }
348 } 351 }
349 async setSeekMicroSecondsTime(value: number) { 352 async setSeekMicroSecondsTime(value: number) {