Search Unity

Videoplayer WebGL (URL) Not working

Discussion in 'WebGL' started by FireHawkX, Apr 21, 2017.

  1. FireHawkX

    FireHawkX

    Joined:
    Apr 26, 2016
    Posts:
    14
    Hi,

    @Schubkraft and @LeonhardP
    I was checking out theses thread here :
    https://forum.unity3d.com/threads/unity-5-6-0b4-issues-with-video-player-in-webgl.452092/
    &
    https://forum.unity3d.com/threads/new-video-player-does-not-work-with-webgl.451777/

    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 ;)
    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)...
    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... ;)

    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....=fa1cd758ef1c0703cf836f6650f41518&oe=58FC00DE

    Thank you for your time and have a nice day!!
     
    Last edited: Apr 22, 2017
  2. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    717
    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
     
  3. FireHawkX

    FireHawkX

    Joined:
    Apr 26, 2016
    Posts:
    14
    Thanks for trying! :) 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.
     
  4. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    717
    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.
     
  5. Schubkraft

    Schubkraft

    Unity Technologies

    Joined:
    Dec 3, 2012
    Posts:
    942
    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.
     
  6. msmithUnity

    msmithUnity

    Joined:
    Jun 19, 2015
    Posts:
    12
    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.
     
  7. FireHawkX

    FireHawkX

    Joined:
    Apr 26, 2016
    Posts:
    14
    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 :)
     
  8. retxab

    retxab

    Joined:
    Oct 19, 2017
    Posts:
    3
    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?
     
  9. FireHawkX

    FireHawkX

    Joined:
    Apr 26, 2016
    Posts:
    14
    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 :p

    -------------------------
    <FilesMatch "\.(php)$">
    <IfModule mod_headers.c>
    Header set Access-Control-Allow-Origin "*"
    </IfModule>
    </FilesMatch>

    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...
     
    byrontik likes this.
  10. retxab

    retxab

    Joined:
    Oct 19, 2017
    Posts:
    3
    Thanks for the reply and warning. I'll see if i can figure it out.
     
  11. GabrielRossito

    GabrielRossito

    Joined:
    Sep 22, 2017
    Posts:
    2
    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
     
    Last edited: Feb 19, 2018
  12. byrontik

    byrontik

    Joined:
    Dec 29, 2013
    Posts:
    5
    This worked for me, thanks guys. I placed the htaccess next to the video on the server to test
     
  13. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    24
     
  14. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    24
  15. savely00

    savely00

    Joined:
    Feb 27, 2014
    Posts:
    34
    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?
     
    Last edited: Mar 22, 2018
  16. ulissescad

    ulissescad

    Joined:
    Oct 31, 2015
    Posts:
    12
  17. Babi_mc

    Babi_mc

    Joined:
    Apr 5, 2018
    Posts:
    5
    Could you please share the name of the script!

    Anyone else has an idea of an asset that can fix the problem?
     
    savely00 likes this.
  18. Babi_mc

    Babi_mc

    Joined:
    Apr 5, 2018
    Posts:
    5

    Hello.

    Did you find a solution for this?
    My first video plays but the rest not :/
     
  19. ulissescad

    ulissescad

    Joined:
    Oct 31, 2015
    Posts:
    12
    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!
     
    JzKonain likes this.
  20. ulissescad

    ulissescad

    Joined:
    Oct 31, 2015
    Posts:
    12
    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!
     
    mchoi, Oxygeniium and savely00 like this.
  21. Babi_mc

    Babi_mc

    Joined:
    Apr 5, 2018
    Posts:
    5
    Thank you for your reply. This did not fix our problem. Our first video play and as soon as you click to go to next video, it does not load and it is just black scree :/
     
  22. ulissescad

    ulissescad

    Joined:
    Oct 31, 2015
    Posts:
    12
    Hi, try to remove de videoPlayer component add a new one and reload de play function. I have more than 1 video and works to me.
     
  23. Stubbornnut

    Stubbornnut

    Joined:
    Oct 3, 2018
    Posts:
    11
    Im sorry, I am trying to follow all of this. for those of us who dont know about or have servers.

    https://cdn-b-east.streamable.com/v...ken=CttEr7drfKOjaBbxLRTnOg&expires=1547356834

    this is my url to my video. is there a way to make this video work from streamable in the unity webgl build. or do you have some reference to this in the unity docs or just something to help me a little further.

    thanks:)
     
  24. Stubbornnut

    Stubbornnut

    Joined:
    Oct 3, 2018
    Posts:
    11
    or do you know of a different host that would work. I am using itch.io
     
  25. vnxxx

    vnxxx

    Joined:
    Jun 7, 2017
    Posts:
    14
    Hi,
    I have problem with use VideoPlayer to play video .mp4 on iOS device
    I check video file by Handheld.PlayFullScreenMovie("file://" + path); -> it play ok
    then, I check with code:
    Code (CSharp):
    1. videoPlayer.renderMode = VideoRenderMode.APIOnly;
    2.         videoPlayer.playOnAwake = false;
    3.         videoPlayer.isLooping = false;
    4.         microphoneSource.playOnAwake = false;
    5.  
    6.         videoPlayer.source = VideoSource.Url;
    7.         videoPlayer.url = path;
    8.         videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
    9.         videoPlayer.controlledAudioTrackCount = 1;
    10.         videoPlayer.EnableAudioTrack(0, true);
    11.         videoPlayer.SetTargetAudioSource(0, microphoneSource);
    12.  
    13.         videoPlayer.prepareCompleted += PrepareCompleted;
    14.         videoPlayer.loopPointReached += EndReached;
    15.         videoPlayer.errorReceived += videoerr;
    16.  
    17.         videoPlayer.Prepare();
    and getting error: VideoPlayer cannot play url: [path]

    I use Unity ver 2018.2.0f2
    thank for any help!
     
  26. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    90
  27. vnxxx

    vnxxx

    Joined:
    Jun 7, 2017
    Posts:
    14
    My video file is on local, not download, in folder Application.persistentDataPath
    and I have try mode "videoPlayer.source = VideoSource.VideoClip", it working ok on editor too, but on iOS device it not, and no log error
    thank for response!
     
unityunity