123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using UnityEngine.Events;
- using System.Collections.Generic;
- namespace RenderHeads.Media.AVProVideo
- {
- [System.Serializable]
- public class MediaPlayerLoadEvent : UnityEvent<string> {}
- [System.Serializable]
- public class MediaPlayerEvent : UnityEvent<MediaPlayer, MediaPlayerEvent.EventType, ErrorCode>
- {
- public enum EventType
- {
- MetaDataReady,
- ReadyToPlay,
- Started,
- FirstFrameReady,
- FinishedPlaying,
- Closing,
- Error,
- SubtitleChange,
- Stalled,
- Unstalled,
- ResolutionChanged,
- StartedSeeking,
- FinishedSeeking,
- StartedBuffering,
- FinishedBuffering,
- PropertiesChanged,
- PlaylistItemChanged,
- PlaylistFinished,
- TextTracksChanged,
- TextCueChanged = SubtitleChange,
-
-
-
-
- }
- private List<UnityAction<MediaPlayer, MediaPlayerEvent.EventType, ErrorCode>> _listeners = new List<UnityAction<MediaPlayer, EventType, ErrorCode>>(4);
- public bool HasListeners()
- {
- return (_listeners.Count > 0) || (GetPersistentEventCount() > 0);
- }
- new public void AddListener(UnityAction<MediaPlayer, MediaPlayerEvent.EventType, ErrorCode> call)
- {
- if (!_listeners.Contains(call))
- {
- _listeners.Add(call);
- base.AddListener(call);
- }
- }
- new public void RemoveListener(UnityAction<MediaPlayer, MediaPlayerEvent.EventType, ErrorCode> call)
- {
- int index = _listeners.IndexOf(call);
- if (index >= 0)
- {
- _listeners.RemoveAt(index);
- base.RemoveListener(call);
- }
- }
- new public void RemoveAllListeners()
- {
- _listeners.Clear();
- base.RemoveAllListeners();
- }
- }
- #if false
- public interface IMediaEvents
- {
- void AddEventListener(UnityAction<MediaPlayer, MediaPlayerEvent.EventType, ErrorCode> call);
- void RemoveListener(UnityAction<MediaPlayer, MediaPlayerEvent.EventType, ErrorCode> call);
- void RemoveAllEventListeners();
- }
- public partial class BaseMediaPlayer
- {
- void AddEventListener(UnityAction<MediaPlayer, MediaPlayerEvent.EventType, ErrorCode> call)
- {
- }
- void RemoveListener(UnityAction<MediaPlayer, MediaPlayerEvent.EventType, ErrorCode> call)
- {
- }
- void RemoveAllEventListeners()
- {
- }
- private MediaPlayerEvent _eventHandler;
- }
- #endif
- }
|