private void CallbackReadyPlayer(string message) { // Texture settings IntPtr texPtr = AVPlayerConnect.AVPlayerGetTexturePtr(avPlayer); Texture2D texture = Texture2D.CreateExternalTexture( 512, 512, TextureFormat.BGRA32, false, false, texPtr); texture.UpdateExternalTexture(texPtr); if (videoObject != null) { Renderer renderer = videoObject.GetComponent <Renderer>(); if (renderer != null) { Vector2 scale = new Vector2(2f, -2f); Material material = renderer.material; material.SetTextureScale("_MainTex", scale); material.SetTexture("_MainTex", texture); renderer.material = material; } } // Render settings StartCoroutine(OnRender()); // Play settings AVPlayerConnect.AVPlayerSetLoop(avPlayer, true); AVPlayerConnect.AVPlayerPlay(avPlayer); }
public void OnPlayMovie() { if (AVPlayerConnect.AVPlayerIsPlaying(avPlayer)) { AVPlayerConnect.AVPlayerPause(avPlayer); } else { AVPlayerConnect.AVPlayerPlay(avPlayer); } }
private void CallbackReadyPlayer(string message) { // Texture settings IntPtr texPtr = AVPlayerConnect.AVPlayerGetTexturePtr(avPlayer); Texture2D texture = Texture2D.CreateExternalTexture( 512, 512, TextureFormat.BGRA32, false, false, texPtr); texture.UpdateExternalTexture(texPtr); videoSizeWidth = AVPlayerConnect.AVPlayerGetVideoWidth(avPlayer); videoSizeHeight = AVPlayerConnect.AVPlayerGetVideoHeight(avPlayer); if (videoObject != null) { Renderer renderer = videoObject.GetComponent <Renderer>(); if (renderer != null) { Material material = renderer.material; if (material != null) { Vector2 scale = new Vector2(1f, -1f); material.SetTextureScale("_MainTex", scale); material.SetTexture("_MainTex", texture); } } } // Render settings StartCoroutine(OnRender()); // Play settings AVPlayerConnect.AVPlayerSetLoop(avPlayer, true); AVPlayerConnect.AVPlayerPlay(avPlayer); // Callbacks var videoSizeEvent = new VideoSizeEvent(); videoSizeEvent.SetCallback(avPlayer, (sender, width, height) => { StartCoroutine(OnUpdateVideoSize(width, height)); }); }