How to load a video file from a url and play it in Unity

This script can help you to load a video file stored somewhere on internet. So by accessing its link, you can load and play it in Unity.

This method can be useful to make minimal installation file size of your program, you don’t have to embed your video but you can ask your user to connect to the internet to play it.

Here is the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;

public class OnlineVideoLoader : MonoBehaviour
	public VideoPlayer videoPlayer;
	public string videoUrl = "yourvideourl";
    // Start is called before the first frame update
    void Start()
		videoPlayer.url = videoUrl;
		videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
		videoPlayer.EnableAudioTrack (0, true);
		videoPlayer.Prepare ();

    // Update is called once per frame
    void Update()

Watch how I did it:

You can download the complete example project from this link:


Leave a Reply

Your email address will not be published.