MediaPlayerControlAsset.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // You need to define AVPRO_PACKAGE_TIMELINE manually to use this script
  2. // We could set up the asmdef to reference the package, but the package doesn't
  3. // existing in Unity 2017 etc, and it throws an error due to missing reference
  4. //#define AVPRO_PACKAGE_TIMELINE
  5. #if (UNITY_2018_1_OR_NEWER && AVPRO_PACKAGE_TIMELINE)
  6. using UnityEngine;
  7. using UnityEngine.Playables;
  8. using UnityEngine.Timeline;
  9. using System.Collections.Generic;
  10. //-----------------------------------------------------------------------------
  11. // Copyright 2020-2021 RenderHeads Ltd. All rights reserved.
  12. //-----------------------------------------------------------------------------
  13. namespace RenderHeads.Media.AVProVideo.Playables
  14. {
  15. [System.Serializable]
  16. public class MediaPlayerControlAsset : PlayableAsset
  17. {
  18. public Object binding { get; set; }
  19. //public ExposedReference<MediaPlayer> mediaPlayer;
  20. public MediaReference mediaReference;
  21. [Range(0f, 1f)]
  22. public float audioVolume = 1f;
  23. public double startTime = -1.0;
  24. public bool pauseOnEnd = true;
  25. public override Playable CreatePlayable (PlayableGraph graph, GameObject owner)
  26. {
  27. var playable = ScriptPlayable<MediaPlayerControlBehaviour>.Create(graph);
  28. var behaviour = playable.GetBehaviour();
  29. //behaviour.mediaPlayer = mediaPlayer.Resolve(graph.GetResolver());
  30. behaviour.audioVolume = audioVolume;
  31. behaviour.pauseOnEnd = pauseOnEnd;
  32. behaviour.startTime = startTime;
  33. behaviour.mediaReference = mediaReference;
  34. behaviour.mediaPlayer = (MediaPlayer)binding;
  35. return playable;
  36. }
  37. }
  38. }
  39. #endif