EventsHandlerExample.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using UnityEngine;
  2. namespace UMP
  3. {
  4. public class EventsHandlerExample : MonoBehaviour
  5. {
  6. public UniversalMediaPlayer _mediaPlayer;
  7. void Start()
  8. {
  9. if (_mediaPlayer != null)
  10. {
  11. _mediaPlayer.AddPlayingEvent(OnPlayerPlaying);
  12. _mediaPlayer.AddTimeChangedEvent(OnPlayerTimeChanged);
  13. _mediaPlayer.AddPositionChangedEvent(OnPlayerPositionChanged);
  14. _mediaPlayer.AddSnapshotTakenEvent(OnPlayerSnapshotTaken);
  15. }
  16. }
  17. public void Play()
  18. {
  19. _mediaPlayer.Play();
  20. }
  21. public void OnPlayerOpening()
  22. {
  23. Debug.Log("OnPlayerOpening");
  24. }
  25. public void OnPlayerBuffering()
  26. {
  27. Debug.Log("OnPlayerBuffering");
  28. }
  29. public void OnPlayerPlaying()
  30. {
  31. Debug.Log("OnPlayerPlaying");
  32. }
  33. public void OnPlayerPaused()
  34. {
  35. Debug.Log("OnPlayerPaused");
  36. }
  37. public void OnPlayerStopped()
  38. {
  39. Debug.Log("OnPlayerStopped");
  40. }
  41. public void OnPlayerEndReached()
  42. {
  43. Debug.Log("OnPlayerEndReached");
  44. }
  45. public void OnPlayerEncounteredError()
  46. {
  47. Debug.Log("OnPlayerEncounteredError");
  48. }
  49. public void OnPlayerTimeChanged(long time)
  50. {
  51. Debug.Log("OnPlayerTimeChanged: " + time);
  52. }
  53. public void OnPlayerPositionChanged(float position)
  54. {
  55. Debug.Log("OnPlayerPositionChanged: " + position);
  56. }
  57. public void OnPlayerSnapshotTaken(string path)
  58. {
  59. Debug.Log("OnPlayerSnapshotTaken: " + path);
  60. }
  61. }
  62. }