void OnEnable() { if (mediaPlayer == null) { mediaPlayer = GetComponent <MediaPlayer.Playback>(); } if (mediaPlayer != null) { mediaPlayer.TextureUpdated += MediaPlayer_TextureUpdated; } }
// Use this for initialization void Start() { if (mediaPlayer == null) { mediaPlayer = GetComponent <MediaPlayer.Playback>(); } if (mediaPlayer != null) { mediaPlayer.DRMLicenseRequested += DRMLicenseRequested; } }
// Use this for initialization void Start() { if (player == null) { player = GetComponent <MediaPlayer.Playback>(); } if (player != null) { player.PlaybackStateChanged += PlaybackStateChangedHandler; } }
private static void MediaPlayback_SubtitleItemEntered(IntPtr thisObjectPtr, [MarshalAs(UnmanagedType.LPWStr)] string subtitleTrackId, [MarshalAs(UnmanagedType.LPWStr)] string textCueId, [MarshalAs(UnmanagedType.LPWStr)] string language, IntPtr textLinesPtr, uint linesCount) { if (thisObjectPtr == IntPtr.Zero) { Debug.LogError("MediaPlayback_SubtitleItemEntered: requires thisObjectPtr."); return; } var handle = GCHandle.FromIntPtr(thisObjectPtr); Playback thisObject = handle.Target as Playback; if (thisObject == null) { Debug.LogError("MediaPlayback_SubtitleItemEntered: thisObjectPtr is not null, but seems invalid."); return; } IntPtr[] ptrArray = new IntPtr[linesCount]; string[] textLines = new string[linesCount]; Marshal.Copy(textLinesPtr, ptrArray, 0, (int)linesCount); for (int i = 0; i < textLines.Length; i++) { string line = Marshal.PtrToStringUni(ptrArray[i]); textLines[i] = line; } #if UNITY_WSA_10_0 if (!UnityEngine.WSA.Application.RunningOnAppThread()) { UnityEngine.WSA.Application.InvokeOnAppThread(() => { thisObject.OnSubtitleItemEntered(subtitleTrackId, textCueId, language, textLines); }, true); } else { thisObject.OnSubtitleItemEntered(subtitleTrackId, textCueId, language, textLines); } #else thisObject.OnSubtitleItemEntered(subtitleTrackId, textCueId, language, textLines); #endif }
private static void MediaPlayback_SubtitleItemExited(IntPtr thisObjectPtr, IntPtr subtitleTrackId, IntPtr textCueId) { if (thisObjectPtr == IntPtr.Zero) { Debug.LogError("MediaPlayback_SubtitleItemExited: requires thisObjectPtr."); return; } var handle = GCHandle.FromIntPtr(thisObjectPtr); Playback thisObject = handle.Target as Playback; if (thisObject == null) { Debug.LogError("MediaPlayback_SubtitleItemExited: thisObjectPtr is not null, but seems invalid."); return; } string trackId = Marshal.PtrToStringUni(subtitleTrackId); string cueId = Marshal.PtrToStringUni(textCueId); #if UNITY_WSA_10_0 if (!UnityEngine.WSA.Application.RunningOnAppThread()) { UnityEngine.WSA.Application.InvokeOnAppThread(() => { thisObject.OnSubtitleItemExited(trackId, cueId); }, true); } else { thisObject.OnSubtitleItemExited(trackId, cueId); } #else thisObject.OnSubtitleItemExited(trackId, cueId); #endif }
private void Awake() { _player = GetComponent <MediaPlayer.Playback>(); }