Videoplayer WebGL (URL) Not working

Hi,

@Schubkraft and @LeonhardP
I was checking out theses thread here :

&

And noticed that video files were not supported when exporting to WebGL… So i redesigned my game to work with URL now instead… i have my video files uploaded to an https server… I put the url in the url… and it works perfectly in game… (takes less than 1 sec to start and its totally acceptable)… It also works fine when exporting in exe for windows…

However, when making a webgl build… the game works… but none of the 4 videos works… one is about 20mb mp4… all others are small 2mb clips… everything else works (no error, no bug)… only the video player is not working…

Yesterday when doing a test on “itch.io”, i went into the console of my browser and copied the following… Honestly, i understand nothing of that… but it might help someone out :wink:
Also note that i tested on Chrome, then firefox then IE… all same issue…
Finally, I only got the following error ONCE… I have been trying anything i could think of for the last 24h and have not gotten that bug since… Video still dont play at all… i can “skip” the not playing video, but nothing is shown (or heard)…
Click to Open Wall of text from console

An error occured running the Unity content on this page. See your browser JavaScript console for more info. The error was:Uncaught abort(106) at Error at jsStackTrace (UT135.asm.framework.unityweb:2:27465) at stackTrace (UT135.asm.framework.unityweb:2:27636) at abort (UT135.asm.framework.unityweb:4:34824) at GMt [Array.GMt] (UT135.asm.code.unityweb:32:574739) at cWa [Array.cWa] (UT135.asm.code.unityweb:14:698252) at _yf [Array._yf] (UT135.asm.code.unityweb:9:20546) at _Gt (UT135.asm.code.unityweb:32:547572) at dynCall [Object.dynCall] (UT135.asm.framework.unityweb:2:15292) at HTMLVideoElement.videoInstances.(anonymous function).onerror (blob:https://v6p9d9t4.ssl.hwcdn.net/7015d49d-2e29-4a67-8ab8-992e0a91803e:2:312416)If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

Invoking error handler due to
Uncaught abort(106) at Error
at jsStackTrace (UT135.asm.framework.unityweb:2:27465)
at stackTrace (UT135.asm.framework.unityweb:2:27636)
at abort (UT135.asm.framework.unityweb:4:34824)
at GMt [Array.GMt] (UT135.asm.code.unityweb:32:574739)
at cWa [Array.cWa] (UT135.asm.code.unityweb:14:698252)
at _yf [Array._yf] (UT135.asm.code.unityweb:9:20546)
at _Gt (UT135.asm.code.unityweb:32:547572)
at dynCall [Object.dynCall] (UT135.asm.framework.unityweb:2:15292)
at HTMLVideoElement.videoInstances.(anonymous function).onerror (blob:https://v6p9d9t4.ssl.hwcdn.net/7015d49d-2e29-4a67-8ab8-992e0a91803e:2:312416)
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.
blob:https://v6p9d9t4.ssl.hwcdn.net/7015d49d-2e29-4a67-8ab8-992e0a91803e:4 Uncaught abort(106) at Error
at jsStackTrace (blob:https://v6p9d9t4.ssl.hwcdn.net/7015d49d-2e29-4a67-8ab8-992e0a91803e:2:27465)
at stackTrace (blob:https://v6p9d9t4.ssl.hwcdn.net/7015d49d-2e29-4a67-8ab8-992e0a91803e:2:27636)
at abort (blob:https://v6p9d9t4.ssl.hwcdn.net/7015d49d-2e29-4a67-8ab8-992e0a91803e:4:34824)
at Array.GMt (blob:https://v6p9d9t4.ssl.hwcdn.net/b33c5b63-7466-4f41-95c5-cfa7ea540d6c:32:574739)
at Array.cWa (blob:https://v6p9d9t4.ssl.hwcdn.net/b33c5b63-7466-4f41-95c5-cfa7ea540d6c:14:698252)
at Array._yf (blob:https://v6p9d9t4.ssl.hwcdn.net/b33c5b63-7466-4f41-95c5-cfa7ea540d6c:9:20546)
at _Gt (blob:https://v6p9d9t4.ssl.hwcdn.net/b33c5b63-7466-4f41-95c5-cfa7ea540d6c:32:547572)
at Object.dynCall (blob:https://v6p9d9t4.ssl.hwcdn.net/7015d49d-2e29-4a67-8ab8-992e0a91803e:2:15292)
at HTMLVideoElement.videoInstances.(anonymous function).onerror (blob:https://v6p9d9t4.ssl.hwcdn.net/7015d49d-2e29-4a67-8ab8-992e0a91803e:2:312416)
If this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.

Edit : for anyone thinking the problem “might” be with my video… or the server hosting the video… they are all working in the engine as well as with a windows build (using url’s)… and i just tried doing an embed of the video themselves on my blogger blogspot webpage and it works as well… :wink:

Edit 2 : I was told to add this by a friend who is a programmer :
“Uncaught (in promise) DOMException: The element has no supported sources.”
along with this image :
https://scontent.fymy1-1.fna.fbcdn.net/v/t34.0-12/18109779_10155294542656942_1015218845_n.png?oh=fa1cd758ef1c0703cf836f6650f41518&oe=58FC00DE

Thank you for your time and have a nice day!!

Could be CORS problem? Maybe you are playing a video from a different site that the security wont allow access to unless you add some kind of crossdomain.xml file to the server’s folder to tell it you are ok with getting files from that server? Something like that, cant remember exactly. Just trying to help

1 Like

Thanks for trying! :slight_smile: Do you think it could be itch.io that prevents a game from connecting to another server to leach the videos? OR that the “000webhost” server i picked to host my mp4 file refuses to share?

Although as I’ve written, I really doubt it would be the 000webhost since the game works fine without changing anything and using those same direct url while in the engine and in a windows exe build, and the video files themselves play fine when hotlinking and embeded in another blogger page.

I think you cant access another website other than the one the unity app is hosted from (like with WWW), it will be blocked. you have to use some other way.

If you are getting the video from another server that isn’t the one hosting the app you need the other server to allow these kinds of connections by setting a fitting CORS policy on the remote server.

2 Likes

Just ran into this as well. The video player seems to swallow the error, so you don’t see in the console that it’s just a CORS error. That was the issue for me though. After hosting the video on a CORS enabled server it streamed fine on a webgl build. I’m sure future Unity builds will output the error to the console.

Yes you are absolutely right (as was Schubkraft answer before), I added a “.htaccess” file in the folder where the video were hosted and everything started working after that :slight_smile:

Hey I’m having a similiar issue of trying to get a video to play in WebGL. Do you think you could share how you did your .htaccess file with me cause I’m really unsure of how to make one?

sure, here is the content of my .htaccess file… dont ask me to explain it i simply copy pasted it from elsewhere and it worked :stuck_out_tongue:


<FilesMatch “.(php)$”>

Header set Access-Control-Allow-Origin “*”

Header set Access-Control-Allow-Origin “*”
Header set Access-Control-Allow-Methods “POST, GET, OPTIONS”
Header set Access-Control-Max-Age “1000”
Header set Access-Control-Allow-Headers “x-requested-with, Content-Type, origin, authorization, accept, client-security-token”

be warned though that you need to actually upload a file to the server and rename it ON the server itself… windows doesnt want a file whose name starts with a dot… so you can create a txt file named x.htaccess, upload it to your server, then remove the x by renaming the file after it has been uploaded…

4 Likes

Thanks for the reply and warning. I’ll see if i can figure it out.

Hello guys, i’m stuck here, everything works but the video wont play on WebGL, but the audio of the video, that wasnt supose to play, works.

I have everthing setup correctly, working fine on standalone and even on editor through the server. Only WebGL isnt working.

Currently using 2017.3…

[EDIT]
Solved, aparently the problem was with the video itself, someway the browser wasnt able to play some container or specific size. I Need to discover more about this, if a discover what really was the problem, I post here.

Thz to this tread, was very helpful

1 Like

This worked for me, thanks guys. I placed the htaccess next to the video on the server to test

I got a demo to work with a free script from the unity store
See

2 Likes

Do you mind to share which script?
Anyone has a suggestion on how to play video in WebGL build for Unity 2017/18 without buying a $50 or more asset?

Hi Brian, this is exactly what I need to do. Any chance you share the scripts with us? Thanks.

Could you please share the name of the script!

Anyone else has an idea of an asset that can fix the problem?

1 Like

Hello.

Did you find a solution for this?
My first video plays but the rest not :confused:

First sorry for my english. I go post my solution:

In editor create a folder with the name StreamingAssets and put your video file into then (the video format I uses is .mp4);

script:
Create a VideoPlayer component and assign in a plan case needs video in scene or camera if you need video full screen;
Use this command to combine the streaming assets path with the video file name and extension:
videoPlayer.url = System.IO.Path.Combine (Application.streamingAssetsPath,“myFile.mp4”);

and, call play mode:
videoPlayer.Play();

works fine to me with mp4 and MOV videos! Unity 5.6.5

Thanks for all answers! Helps a lot!

1 Like

First sorry for my english. I go post my solution:

In editor create a folder with the name StreamingAssets and put your video file into then (the video format I uses is .mp4);

script:
Create a VideoPlayer component and assign in a plan case needs video in scene or camera if you need video full screen;
Use this command to combine the streaming assets path with the video file name and extension:
videoPlayer.url = System.IO.Path.Combine (Application.streamingAssetsPath,“myFile.mp4”);

and, call play mode:
videoPlayer.Play();

works fine to me with mp4 and MOV videos! Unity 5.6.5

Thanks for all answers! Helps a lot!

3 Likes