I’m trying to use the new VideoPlayer feature to play a video from a website (my dropbox link). I can’t seem to figure out the right url format to get the video to play. I’ve just been copying the video link from dropbox and putting it in as the url but that doesn’t seem to work. I’ve also tried videos from other websites and couldn’t get those to work either. I tried actually bringing the video file into unity and playing it directly instead of through the url and it works fine. Here’s the code I have: (I press a button in the scene to begin playing the video)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class Test : MonoBehaviour {
Camera cam;
UnityEngine.Video.VideoPlayer vid;
AudioSource aud;
void Start () {
cam = Camera.main;
aud = cam.GetComponent<AudioSource> ();
vid = cam.GetComponent<UnityEngine.Video.VideoPlayer> ();
vid.renderMode = UnityEngine.Video.VideoRenderMode.CameraNearPlane;
vid.url = "https://www.dropbox.com/s/cquqv1zb31b04p4/Vid-648155715.ogv?dl=0";
vid.audioOutputMode = VideoAudioOutputMode.AudioSource;
vid.EnableAudioTrack (0, true);
vid.SetTargetAudioSource (0, aud);
vid.Prepare ();
}
void Update () {
Debug.Log (vid.isPlaying);
}
public void PlayMovie(){
vid.Play ();
}
}
Does the video have to be in a certain format for unity to play it? And how can I fix this so I can play the video through the url? Or would there be a better way to handle playing these videos without streaming them from a website? (I intend to have hundreds of videos so I didn’t think having them all locally in unity would be very efficient)