void Update() { if (!overlay.isExternalSurface) { var displayTexture = videoPlayer.texture != null ? videoPlayer.texture : Texture2D.blackTexture; if (overlay.enabled) { if (overlay.textures[0] != displayTexture) { // OVROverlay won't check if the texture changed, so disable to clear old texture overlay.enabled = false; overlay.textures[0] = displayTexture; overlay.enabled = true; } } else { mediaRenderer.material.mainTexture = displayTexture; mediaRenderer.material.SetVector("_SrcRectLeft", overlay.srcRectLeft.ToVector()); mediaRenderer.material.SetVector("_SrcRectRight", overlay.srcRectRight.ToVector()); } isPlaying = videoPlayer.isPlaying; } else { NativeVideoPlayer.SetListenerRotation(Camera.main.transform.rotation); isPlaying = NativeVideoPlayer.IsPlaying; } }
public void Rewind() { if (overlay.isExternalSurface) { NativeVideoPlayer.SetPlaybackSpeed(-1); } else { videoPlayer.playbackSpeed = -1; } }
public void Pause() { if (overlay.isExternalSurface) { NativeVideoPlayer.Pause(); } else { videoPlayer.Pause(); } isPlaying = false; }
public void Play() { if (overlay.isExternalSurface) { NativeVideoPlayer.Play(); } else { videoPlayer.Play(); } isPlaying = true; }
public void Stop() { if (overlay.isExternalSurface) { NativeVideoPlayer.Stop(); } else { videoPlayer.Stop(); } IsPlaying = false; }
public void SetPlaybackSpeed(float speed) { // clamp at 0 speed = Mathf.Max(0, speed); if (overlay.isExternalSurface) { NativeVideoPlayer.SetPlaybackSpeed(speed); } else { videoPlayer.playbackSpeed = speed; } }
void Update() { UpdateShapeAndStereo(); if (!overlay.isExternalSurface) { var displayTexture = videoPlayer.texture != null ? videoPlayer.texture : Texture2D.blackTexture; if (overlay.enabled) { if (overlay.textures[0] != displayTexture) { // OVROverlay won't check if the texture changed, so disable to clear old texture overlay.enabled = false; overlay.textures[0] = displayTexture; overlay.enabled = true; } } else { mediaRenderer.material.mainTexture = displayTexture; mediaRenderer.material.SetVector("_SrcRectLeft", overlay.srcRectLeft.ToVector()); mediaRenderer.material.SetVector("_SrcRectRight", overlay.srcRectRight.ToVector()); } IsPlaying = videoPlayer.isPlaying; PlaybackPosition = (long)(videoPlayer.time * 1000L); #if UNITY_2019_1_OR_NEWER Duration = (long)(videoPlayer.length * 1000L); #else Duration = videoPlayer.frameRate > 0 ? (long)(videoPlayer.frameCount / videoPlayer.frameRate * 1000L) : 0L; #endif } else { NativeVideoPlayer.SetListenerRotation(Camera.main.transform.rotation); IsPlaying = NativeVideoPlayer.IsPlaying; PlaybackPosition = NativeVideoPlayer.PlaybackPosition; Duration = NativeVideoPlayer.Duration; if (IsPlaying && (int)OVRManager.display.displayFrequency != 60) { OVRManager.display.displayFrequency = 60.0f; } else if (!IsPlaying && (int)OVRManager.display.displayFrequency != 72) { OVRManager.display.displayFrequency = 72.0f; } } }
public void Play(string moviePath, string drmLicencesUrl) { if (moviePath != string.Empty) { Debug.Log("Playing Video: " + moviePath); if (overlay.isExternalSurface) { OVROverlay.ExternalSurfaceObjectCreated surfaceCreatedCallback = () => { Debug.Log("Playing ExoPlayer with SurfaceObject"); NativeVideoPlayer.PlayVideo(moviePath, drmLicencesUrl, overlay.externalSurfaceObject); NativeVideoPlayer.SetLooping(LoopVideo); }; if (overlay.externalSurfaceObject == IntPtr.Zero) { overlay.externalSurfaceObjectCreated = surfaceCreatedCallback; } else { surfaceCreatedCallback.Invoke(); } } else { Debug.Log("Playing Unity VideoPlayer"); videoPlayer.url = moviePath; videoPlayer.Prepare(); videoPlayer.Play(); } Debug.Log("MovieSample Start"); isPlaying = true; } else { Debug.LogError("No media file name provided"); } }