Question by
ToChoVan · Jul 20, 2021 at 01:05 PM ·
augmented-realityvideo streaming
How to load a video from url during AR core session?
Hello everyone, I've been facing a challenge, while trying to load a video from url during augmented reality session with AR core.
Previously I've been using videos locally placed in the folder, but I want to optimize the size of the app, that's why I need to use URLs.
This is the code I've been using for URLs:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Video; using GoogleARCore;
public class ScreenV : MonoBehaviour { [SerializeField] string[] _VideoURLs; public AugmentedImage Image; private VideoPlayer videoPlayer;
void Start()
{
videoPlayer = GetComponent<VideoPlayer>();
videoPlayer.source = VideoSource.Url;
}
void Update()
{
if (Session.Status != SessionStatus.Tracking)
return;
if (Image == null || Image.TrackingState != TrackingState.Tracking)
{
return;
}
if (Image != null || Image.TrackingState == TrackingState.Tracking)
{
videoPlayer.url = _VideoURLs[Image.DatabaseIndex];
videoPlayer.Play();
}
transform.localScale = new Vector3(Image.ExtentX, Image.ExtentZ, 1);
Any thoughs or ideas? Thank you
Comment