public void OnVideoChosen(string filePath) { videoRotation = NativeGallery.GetVideoProperties(filePath).rotation; string videoURL = "file://" + filePath; videoPlayer.url = filePath; videoPlayer.Prepare(); }
public void LoadVideoInsidePicture() { NativeGallery.Permission permission = NativeGallery.GetVideoFromGallery((path) => { Debug.Log("Video path: " + path); if (path != null) { foreach (GameObject element in GameObject.FindGameObjectsWithTag("TakePictureBtn")) { element.SetActive(false); } NativeGallery.VideoProperties videoProperties = NativeGallery.GetVideoProperties(path); GameObject pictureVideo = Instantiate(Resources.Load <GameObject>("Prefabs/Picture/PictureVideo")); StreamVideo streamScript = pictureVideo.GetComponent <StreamVideo>(); pictureVideo.GetComponent <PictureController>().SetMediaPath(path); if (videoProperties.rotation == 180 || videoProperties.rotation == 0) { streamScript.SetRotationVideo(videoProperties.rotation); } else { streamScript.SetRotationVideo(videoProperties.rotation - 180); } streamScript.SetPath(path); streamScript.LoadVideoInsidePicture(); EnableButtonPhoto(); confirmSavePhotoBtn.GetComponent <SavePhotoController>().setPicture(pictureVideo); confirmCancelPhotoBtn.GetComponent <SavePhotoController>().setPicture(pictureVideo); } }, "Select a video"); Debug.Log("Permission result: " + permission); }
public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult) { UnityEngine.Debug.Log("found"); GameObject gameObject = UnityEngine.Object.Instantiate(ImageTargetTemplate.gameObject); MainPlayer = gameObject.transform.GetChild(0).gameObject; GameObject gameObject2 = null; if (gameObject2 != null) { gameObject2.transform.SetParent(gameObject.transform); } if ((bool)ImageTargetTemplate) { ImageTargetBehaviour imageTargetBehaviour = (ImageTargetBehaviour)TrackerManager.Instance.GetTracker <ObjectTracker>().GetTargetFinder <ImageTargetFinder>().EnableTracking(targetSearchResult, gameObject); } TargetFinder.CloudRecoSearchResult cloudRecoSearchResult = (TargetFinder.CloudRecoSearchResult)targetSearchResult; mTargetMetadata = cloudRecoSearchResult.MetaData; if (Directory.Exists(Path.Combine(Application.persistentDataPath, "YourUnzippedVideos"))) { url = Path.Combine(Application.persistentDataPath, "YourUnzippedVideos"); url = Path.Combine(url, mTargetMetadata); } txt.text = url; if (File.Exists(url)) { float rotation = NativeGallery.GetVideoProperties(url).rotation; txt.text = rotation.ToString(); ImageTarget imageTarget = gameObject.GetComponent <ImageTargetBehaviour>().ImageTarget; newScale1 = imageTarget.GetSize().x / imageTarget.GetSize().y; MainPlayer.transform.localScale = new Vector3(newScale1, 1f, newScale1); if (newScale1 > 1f && rotation == 0f) { float y = 1f / newScale1; MainPlayer.transform.localScale = new Vector3(1f, y, 1f); } if (newScale1 > 1f && rotation == 90f) { MainPlayer.transform.Rotate(new Vector3(0f, 0f, -90f)); float y = 1f / newScale1; MainPlayer.transform.localScale = new Vector3(y, 1f, 1f); } if (newScale1 > 1f && rotation == 180f) { MainPlayer.transform.Rotate(new Vector3(0f, 0f, -180f)); float y = 1f / newScale1; MainPlayer.transform.localScale = new Vector3(1f, y, 1f); } if (newScale1 > 1f && rotation == 270f) { MainPlayer.transform.Rotate(new Vector3(0f, 0f, -270f)); float y = 1f / newScale1; MainPlayer.transform.localScale = new Vector3(y, 1f, 1f); } if (newScale1 > 1f && rotation == 360f) { MainPlayer.transform.Rotate(new Vector3(0f, 0f, -360f)); float y = 1f / newScale1; MainPlayer.transform.localScale = new Vector3(1f, y, 1f); } if (newScale1 < 1f) { MainPlayer.transform.localScale = new Vector3(newScale1, 1f, 1f); } if (newScale1 < 1f && rotation == 180f) { MainPlayer.transform.Rotate(new Vector3(0f, 0f, -180f)); MainPlayer.transform.localScale = new Vector3(newScale1, 1f, 1f); } if (newScale1 < 1f && rotation == 90f) { MainPlayer.transform.Rotate(new Vector3(0f, 0f, -90f)); MainPlayer.transform.localScale = new Vector3(1f, newScale1, 1f); } if (newScale1 < 1f && rotation == 270f) { MainPlayer.transform.Rotate(new Vector3(0f, 0f, -270f)); MainPlayer.transform.localScale = new Vector3(1f, newScale1, 1f); } if (newScale1 < 1f && rotation == 360f) { MainPlayer.transform.Rotate(new Vector3(0f, 0f, -360f)); MainPlayer.transform.localScale = new Vector3(newScale1, 1f, 1f); } txt2.text = MainPlayer.transform.localScale.ToString(); MainPlayer.GetComponent <VideoPlayer>().url = url; } else { MainPlayer.transform.localScale = new Vector3(0f, 0f, 0f); } }