AVideoSlide.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. using UnityEngine.UI;
  6. using XRTool.Util;
  7. public class AVideoSlide : PointerHandler
  8. {
  9. public AVProVideoPlayer aVdieoPlayer;
  10. public Slider slider;
  11. public static bool isDown = false;
  12. // Start is called before the first frame update
  13. void Start()
  14. {
  15. }
  16. // Update is called once per frame
  17. void Update()
  18. {
  19. //if (slider && vidoPlayer && isDown == false)
  20. //{
  21. // slider.value = float.Parse(vidoPlayer.frame.ToString()) / float.Parse(vidoPlayer.frameCount.ToString());
  22. //}
  23. }
  24. void sliderChanged(float per)
  25. {
  26. if (slider && aVdieoPlayer)
  27. {
  28. aVdieoPlayer.SetSeek( per);
  29. //float targetFrame = vidoPlayer.frameCount * per;
  30. //vidoPlayer.frame = (long)targetFrame;
  31. }
  32. }
  33. public override void OnPointerDown(PointerEventData eventData)
  34. {
  35. base.OnPointerDown(eventData);
  36. aVdieoPlayer.Pause();
  37. isDown = true;
  38. }
  39. public override void OnPointerUp(PointerEventData eventData)
  40. {
  41. base.OnPointerUp(eventData);
  42. sliderChanged(slider.value);
  43. TimerMgr.Instance.CreateTimer(()=> {
  44. aVdieoPlayer.Play();
  45. },0.2f);
  46. isDown = false;
  47. }
  48. }