Search Unity

Video Player on WebGL

Discussion in 'Web' started by Iccontemporary, Aug 6, 2020.

  1. Iccontemporary

    Iccontemporary

    Joined:
    Aug 6, 2020
    Posts:
    19
    Hey everyone

    I have this project I've been trying to upload to Itch.io with a WebGL build but when the build includes 4 of the videos that playing during the project, itch says the file is too large and can't be uploaded though I have compressed them already but does anyone have any tips on how to perfect this?

    Additionally, a lot of the threads I have found said that video player doesn't even work while running on WebGL. Is there a way to get around this?

    The project is a virtual art exhibition so the videos can't be removed from the show.

    I'm fairly new to using unity and even these forums so apologies if there isn't enough information
     
  2. henrikvonsoderstrom

    henrikvonsoderstrom

    Joined:
    Apr 16, 2020
    Posts:
    5
    Hey - the only way I got videos in WebGL to work is by pointing the video player in the Unity API to an URL instead of building the video files into the project. Your file will be smaller without the videos included, but you will need to find hosting for the videos somewhere.

    Also there are a bunch of issues with videoplay in WebGL - this video helped me get it to work:

    Also, video playing on startup can be a problem as a lot of browsers block autoplay - a simple way around this is to make some sort of "play" button, as the browser will allow autoplay once the user has interacted with the page.
     
    wxxhrt and jaimelugo like this.
  3. DWMcDonald

    DWMcDonald

    Joined:
    Sep 10, 2021
    Posts:
    1
    Does anyone know of a preferably free site that will host videos and support a direct link to them so that I can have video in my WebGL project? I hate to be cheap, but right now I just want to host a couple of small videos for learning purposes only. If there's nothing free, can you recommend a reasonably priced, easy to use alternative? Thanks!
     
  4. kyboon

    kyboon

    Joined:
    Dec 23, 2015
    Posts:
    1
    Hey sorry for the late answer, but you can simply use youtube to host your video. If you don't want the video to show up on your channel, just set them to unlisted.
     
  5. djon801

    djon801

    Joined:
    Jul 28, 2014
    Posts:
    2
    YouTube links are not direct, they do not work in unity
     
    luisquid and Androser1313 like this.
  6. thecloudkeeper

    thecloudkeeper

    Joined:
    Sep 21, 2021
    Posts:
    28
    I know it's been a while, but you actually can stream YouTube videos with the VideoPlayer component. Check out this GitHub repository. WebGL is not supported due to CORS, however.
     
  7. MagicWebSolutions

    MagicWebSolutions

    Joined:
    Jan 16, 2023
    Posts:
    3
    Hi there,

    You can try using the "Video Player for WebGL" asset available on the Unity Asset Store. This asset is known for enabling smooth video playback for WebGL builds.

    You might consider optimizing the videos further to reduce their file size. Tools like HandBrake or FFmpeg can help you compress videos without compromising too much on quality.
    For video hosting Cloudinary is an option, but there are many other options.

    Keep coding!
     
  8. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    547
    > Additionally, a lot of the threads I have found said that video player doesn't even work while running on WebGL. Is there a way to get around this?

    Unity's default video player has issues playing videos on browsers running on Apple devices. In addition, because Unity has to make a component that works for many build targets, it can't specialize on features that are present just on one target.

    Video Player WebGL is a plugin I made to address the issues above. It aims to bring all the video web features it can to Unity and work flawlessly across different browsers.
     
    Last edited: Nov 28, 2023
  9. KamilCSPS

    KamilCSPS

    Joined:
    May 21, 2020
    Posts:
    448
    Just a note @Marks4 ; prf.hn links don't seem to work. Better linking directly to the asset.
     
    Marks4 likes this.
  10. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,437