Search Unity

No way to play a video with VideoPlayer with webgl after build (URL or video in assets)

Discussion in 'Web' started by Jhereck, Oct 17, 2018.

  1. Jhereck

    Jhereck

    Joined:
    Oct 15, 2018
    Posts:
    2
    Hi,

    I spend a lot of time trying to play a video in Webgl and it did not work.

    I tried :

    - with URL
    - with video in assets (checking transcode or/and adding in preload)
    - with different scripts
    - with different versions of Unity (2018.1, 2018.2 and 2018.3 beta)

    It's working in editor, but they did not play in browser after build.

    Help pls !
     
    Last edited: Oct 17, 2018
  2. Jhereck

    Jhereck

    Joined:
    Oct 15, 2018
    Posts:
    2
    Solved it was a CORS problem : no way to access to online videos as soon as project is built, unless videos are stored on a server you can setup CORS with a .htaccess (or you project is also stored on this server).

    If you have a doubt check "developper" in build option so you can look at error when the browser load the window.
     
  3. mustang4484

    mustang4484

    Joined:
    Feb 11, 2018
    Posts:
    3
    Hello, i've a similar problem….in the editor my "video streaming" play, but when build my project and open my weblink the video is only blank and doesn't play.
    can you help me?
    Thank you!!
     
  4. CCouto96

    CCouto96

    Joined:
    May 18, 2016
    Posts:
    44
    Hey. I am also having a similar issue with WebGL not playing videos after the build.
    If possible, can you give me step-by-step directions on how you managed to get yours to work? I have been trying for a while and haven't had much luck. I just want to make sure I have done everything correctly in Unity up to the point when I export and then figure out how to get the game working on a website.

    Thanks!
     
  5. rmills1997

    rmills1997

    Joined:
    Oct 12, 2019
    Posts:
    4
    Any updates?
     
  6. blabberbytes

    blabberbytes

    Joined:
    Nov 22, 2014
    Posts:
    13
    I have same issue.
     
  7. Kloper

    Kloper

    Joined:
    Jan 28, 2014
    Posts:
    93
    Video and Unity's webgl is a real pain... but here are some tips that may help some people.
    First, try to keep your videos in the StreamingAssets folder and access them using Application.streamingassetspath or what ever the command is called.
    The other issue is that some browser dont allow automatic video playback without user interaction. Try to play your video once the user clicks inside the game.. doesnt have to be a button, but just a click event.
    Then... unity's video player and chrome dont seem to like each other at all.. but it seems to work most of the time in firefox and safari. (in chrome, sometimes it helps if you turn off hardware acceleration)
    Its always usefull to activate the console in your browser and see what the actual error is.
    Hope this helps somebody...
     
    JoRangers likes this.
  8. TadeuszKantor

    TadeuszKantor

    Joined:
    Jul 28, 2019
    Posts:
    4
    Hi everyone ! I'm trying to have many instances of the same video inside of a game on WEB GL... Works in the editor but whenever i try to open the build.index, it just doesn't show the video..
    And i get this error in the console.. Blocking of a cross-origin request: the "Same Origin" policy does not allow you to consult the remote resource located on file: /// C: / Users / j / Documents / Presquils / Assets / StreamingAssets / MPL % 20-% 20Panama.mp4. Reason: CORS request does not use http.
    i'm a newbie in web but advanced in Unity..
    thanks a lot !!
     
  9. InesHilz

    InesHilz

    Joined:
    Aug 31, 2017
    Posts:
    1
    Hello there!
    I made a VideoPlayer work in WebGL with the videos in webm VP8 Format in the Streaming Assets folder.
    But, every video looks really weird, like it has a white overlay or the white areas are over exposed?
    Any tips for that? :/
     
  10. sumpfkraut

    sumpfkraut

    Joined:
    Jan 18, 2013
    Posts:
    242
  11. owaisahmed93

    owaisahmed93

    Joined:
    Jul 9, 2020
    Posts:
    1
    Alright, so I managed to get a work around to all this, so I hope this helps someone down the line. I solved the problem with CORS by hosting the video on DigitalOcean Spaces (costs ~ $5 a month, you can get $100 in free credit too) , then going into the Settings> CORS Configurations > Add and just add *
    As a warning, * allows all GET requests, and you can of course specify exactly what you want to allow in, but this should solve your problem.
     
  12. Marks4

    Marks4

    Joined:
    Feb 25, 2018
    Posts:
    547