Forum rules - please read before posting.

Local File for Video Player URL [SOLVED]

edited February 2018 in Technical Q&A
Hi I am using Adventure Creator 1.61.2 and Unity 2017.3. I was having issues with playing a local movie for the video player and thought this might help someone else. I kept getting the error Player failed to load "http://" and/or VideoPlayer cannot play url : http://. This got resolved when I entered the following for my local file: file:///path/to/video.

Comments

  • You're using WebGL platform?  Unity requires that movie files be found via path, instead of assigning an asset file in a field as with other platforms.
  • edited September 29

    Hello everyone! I wanted to update this thread with the steps I had to make in order for my game video cinematics to be able to load on Itch.io (WebGL). What you previously commented is included and expanded in this instructions.

    I hope it will be useful for anyone uploading to Itch.io.

    Preparation:

    • All the cinematic videos mut be in .mp4 format (Video Codec: H.264, Audio Codec: AAC), that's for browser compatibility.
    • All videos mut be put inside a folder called StreamingAssets inside your Assets folder in your project (Assets/StreamingAssets/, at the same level where you would find the "AdventureCreator" and "Scenes" folders).
    • Names of the video files shouldn't have spaces or any special characters in them. Something like "my_video_01.mp4" will be ok.

    Steps:

    1. In the GameObject's Video Player component in the Hierarchy, the Source must be URL and the URL must be left empty.
    2. In the same GameObject you can add a script (let's call it UpdateLocalVideo.cs) that will set the correct path at runtime (meaning that when it's hosted on Itch.io servers, it will set the correct url for each video). This script will receive the filename of the video that must be played (e.g.: "my_video_01.mp4") in its Video File Name field.
    3. In the scene Hierarchy, in the ActionList that triggers the video, any Engine: Play movie clip actions, must have their Movie URL: field empty (AC adds a "http://" string in them, you must remove it to avoid conflics, otherwise it will throw a runtime error.

    Here's the content of the UpdateLocalVideo.cs script:

    using UnityEngine;
    using UnityEngine.Video;
    
    public class UpdateLocalVideo : MonoBehaviour
    {
        [SerializeField] string videoFileName;
    
        void Start()
        {
            UpdateUrl();
        }
    
        public void UpdateUrl()
        {
            VideoPlayer videoPlayer = GetComponent<VideoPlayer>();
    
            if(videoPlayer)
            {
                // Combine StreamingAssets path with your video file name
                string videoPath = System.IO.Path.Combine(Application.streamingAssetsPath, videoFileName);
                videoPlayer.url = videoPath;
            }
        }
    }
    
    

    That's it! Now videos will play ok on Itch.io :)

    PS: I went ahead and added this as a Wiki page as well: https://adventure-creator.fandom.com/wiki/Make_local_videos_play_on_Itch.io_(WebGL)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.