Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

WebGL Movie Texture

Discussion in 'WebGL' started by jareds, Oct 5, 2015.

  1. jareds

    jareds

    Joined:
    May 8, 2008
    Posts:
    207
    Hi,

    We're using a great plugin that lets us play movies inside of Unity WebGL apps:

    https://www.assetstore.unity3d.com/en/#!/content/38369

    The only issue we're having is that this doesn't work with Microsoft Edge. We're getting the error message:

    INVALID_VALUE: texImage2D: This texture source is not supported

    Has anyone else had luck with this plugin and Edge? I know Unity WebGL isn't officially supported on Edge, but otherwise our app seems to be working.

    Thanks,
    Jared
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
  3. jareds

    jareds

    Joined:
    May 8, 2008
    Posts:
    207
    Thanks for the information.
     
  4. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Hi Jonas,

    Not able to get it to work. Getting build errors. Assets/Plugins/WebGLMovieTexture.cs(106,63): warning CS0618: `UnityEngine.Texture.GetNativeTextureID()' is obsolete: `Use GetNativeTexturePtr instead.'

    Can you advise what scripts to add to a plane asset to make it play, pause, search in WebGl. Need to do this for a work project and put it on our website. Im sure a lot of guys are trying to get their stuff on webGL but not pro coders. Pretty please!
     
  5. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    It seems to work for me on firefox. Which Unity are you using ?

    the only problem i had is that if you import the package into an empty project, you will need to disable "Strip Engine Code" to make it work.
     
  6. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Hi Im using Unity Pro 5.2.2!
    Is there a video on how to make this work. Searched YouTube and Vimeo...nada, zilch.
     
  7. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
  8. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Thanks Marco for any help... Im really lost in this one.
     
  9. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    It looks like you are using the UnityEngine.MovieTexture class, which is not supported on WebGL. Instead you should change your code to use a replacement solution, like the WebGLMovieTexture plugin. So basically you would need to use the WebGLMovieTexture class instead of MovieTexture.

    Your code should probably look like:

    Code (csharp):
    1. #if UNITY_WEBGL
    2. // use WebGLMovieTexture here...
    3. #else
    4. // use MovieTexture on other platforms
    5. #endif
    does that help ?
     
  10. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Nope..those errors are from scripts that are not even in the scene im trying to build. I need a working sample to be clear on this...
     
  11. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Ill delete those scripts and still get error building...
     
  12. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Hey It worked.... Finally!!! After deleting all conflicting scripts in the project. So that means i have to made a new project for these WebGl stuff. Now i have to figure out how to add it to my plane asset. Noticed there was no Seek function though and Chrome throws up some alerts which i had to block for it to play.
     
  13. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Now i get a WebGL folder in Assets owth scripts and 51 red alerts.
    upload_2015-11-25_18-9-55.png
     
  14. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    upload_2015-11-25_20-5-7.png
    This one test scene i downloaded only plays the audio....???
     
  15. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    no, there should be video as well. did you import the package into an empty project ? That would probably be the easiest way to check if it works, just make sure you disable Strip Engine Code
     
  16. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
  17. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    upload_2015-11-26_17-55-28.png


    I tried opening the folder as new project and i get the scripts missing in the Cube.See pic above. I load the scripts as Streamingmovietexture.cs and MovieGuiButtons. The build and run.

    Do i need to change the path url of movie or something...
     
  18. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Tried build now... nothing... no sound too.
     
  19. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    upload_2015-11-26_18-8-17.png

    I just want to get a small Video to work in this Point Of Sale unit demo and use it on our website. with play pause and something with change Video functionality array. Rotate Camera functionality is added to zoom in and around it.
     
  20. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    This is just not happening..maybe not trying the right code..
     
  21. crushforth

    crushforth

    Joined:
    Jul 22, 2010
    Posts:
    113
    @briandcruz67 What browser are you using? And what does the developer debug console say? Are there any errors about maybe not being able to create non power of 2 textures? I've see code that works perfectly on OS X fail on slightly older Windows machines. Also I've had problems getting .ogv videos working on safari on a mac and had to switch to .mp4's.

    WebGL videos do work using this method though. I had it working in a project but switched it out in favour of showing youtube videos because of the aforementioned texture creation issue on very specific windows machines.

    To see the debug console in chrome goto "right hand hamburger menu -> More tools -> Developer tools -> Console". Most other browsers have the same console. Should highlight any errors.

    If you still can't get it working send me a message and I'll try and put together a sample that worked for me.
     
  22. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Hey Crushforth,

    Ok let me do that too and check browser console. As of now unity console has no errors and build launches in Chrome and made with Unity logo happens. only the Cube is blank but i can hear the audio from the Chrome_imF.mp4 and small.ogv

    Checking and will get back to you. Thanks for the help ...
     
  23. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    upload_2015-12-1_11-34-58.png
    I opened the console and there are several warning... wish i knew what they mean.


    Release/WebGLTest.js:1 'webkitMovementY' is deprecated. Please use 'movementY' instead.


    attachment_editor.js?_v=edca9518:13 Attachments changed, total files: 0, images: 0
    xenforo.js?_v=edca9518:209 XenForo.init() 152ms. jQuery 1.11.0/1.2.8-dev
    (index):1 Refused to execute script from 'http://unity3d.com/ads/cp.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
    xenforo.js?_v=edca9518:342 Event: AutoValidationDataReceived
    xenforo.js?_v=edca9518:344 Event: AutoValidationComplete
    xenforo.js?_v=edca9518:223 XenForo.activate(e.fn.init[1])
    attachment_editor.js?_v=edca9518:13 Attachments changed, total files: 0, images: 0
    xenforo.js?_v=edca9518:223 XenForo.activate([li#attachment164038.AttachedFile.AttachedImage.secondaryContent.__XenForoActivator, prevObject: e.fn.init[1], context: undefined])
    attachment_editor.js?_v=edca9518:13 Attachments changed, total files: 1, images: 1


    OPENGL LOG: Creating OpenGL ES 2.0 graphics device
    index.html:30 WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD' has no vertex shader
    index.html:30 WARNING: Shader Unsupported: 'Standard' - Pass 'FORWARD_DELTA' has no vertex shader
    index.html:30 WARNING: Shader Unsupported: 'Standard' - Pass 'SHADOWCASTER' has no vertex shader
    index.html:30 WARNING: Shader Unsupported: 'Standard' - Pass 'DEFERRED' has no vertex shader
    index.html:30 WARNING: Shader Unsupported: 'Standard' - All passes removed
    Release/WebGLTest.js:1 'webkitMovementX' is deprecated. Please use 'movementX' instead.
    Release/WebGLTest.js:1 Creating WWW for ogv
     
  24. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Would love to have a sample with video working on a plane gameobject which i could use in my demo. I can have .ogg , webm and mp4 format ready so they play.
     
  25. crushforth

    crushforth

    Joined:
    Jul 22, 2010
    Posts:
    113
    Hi Brian, I downloaded the version from the asset store and re-attached the missing mono behaviours. When I 'Build And Run" it takes ages but spawns my default browser (chrome) at localhost:xxxx. You need to click the play button to start the video. This all works for me on a mac with Unity 5.2.3f1

    There is a pre build 'test' folder in there that you can try. Right click on the test/index.html and open it in Firefox (chrome wont allow web gl from the local drive, only when deployed to a server)

    Sorry it took so long. Let me know if it works out for you. Also this version is quite good https://github.com/jtothebell/UnityStreamingMovieTexture as it supports non webgl video playback for when you're running in the editor (may need some changes to actually get it to work).

    Anyway this is my version slightly modified from the asset store:
    https://www.dropbox.com/s/uwet0laptvbbh8v/WebGLVideo.zip?dl=0
     

    Attached Files:

    Last edited: Dec 2, 2015
  26. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Hey Thanks bud, will download your version as i have the github one already.. need to crack the problem with that one later.
    Really thanks for getting back
     
  27. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Hi Crushforth,

    Im confused as this seems to be the same as the one i got to work on 25th Nov.(See above). The cube is generated from the testvideo.cs code right. The cube in the scenetest is not needed correct as its regenerated. The one with the missing mono scripts are added to a cube not generated by code so i wanted to test in on a "plane" gameObject. For me that works on the sound not video somehow. All the errors are from that one....

    That would help me get my demo of actual video book start working playing a Christmas video etc.
     
  28. crushforth

    crushforth

    Joined:
    Jul 22, 2010
    Posts:
    113
    Oh I think I misunderstood. I thought you were having problems getting the video to work in webgl but everything works, you just want it on your own plane/mesh and not the cube? Is that right. Those scripts replace the main texture on the material assigned to a 'Renderer' on the same object. Should work on any mesh with no code changes. To get it to look right on your 3d book you'll have to make sure the mesh texture coordinates are setup correctly. Hope that makes sense.
     
  29. briandcruz67

    briandcruz67

    Joined:
    Mar 12, 2012
    Posts:
    27
    Nope...mesh texture coordinates? In standalone just work fine but no idea about webGL..
     
  30. jaised

    jaised

    Joined:
    Jul 5, 2012
    Posts:
    17
    @jonas echterhoff
    This plugin works great with StreamingAssets/ Is there any ways to load video internally via Resources.Load or via AssetBundles? Not sure what the url would be for Resources or AssetBundles (once downloaded). Is this something getting worked on behind the scenes for future support? Appreciate any feedback.
     
  31. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    No, this system will not work with AssetBundles or Resources. Why would you want to use it that way?

    Work is on the way for a complete replacement of Unity's built-in MovieTexture class, but it is too early for an ETA or details.
     
    Last edited: Apr 18, 2016
    Chronovore and cogentEd like this.
  32. cogentEd

    cogentEd

    Joined:
    Aug 3, 2015
    Posts:
    6
    I'm very excited to hear this! Something that worked like a movie texture (not a movie player [mobile]) but on all platforms would be fantastic.
     
  33. jaised

    jaised

    Joined:
    Jul 5, 2012
    Posts:
    17
    We are building a game that uses many videos and as WebPlayer becomes unsupported, we are trying to build for WebGL. However, with StreamingAssets, each time the video is required, it has to be streamed or downloaded before it is used. Our schools have a very iffy connection and waiting for downloads midgame really breaks immersion. I would like to have the videos stored with the cache or internally, so the user will only have to download once. AssetBundles control the cache with versions, and Resources allows internal load.

    I have already written a wrapper interfacing the MovieTexture and WebGLTexture. It all works great, there is just the caveat of having to stream the video each time. Ideally, I'd like to download the AssetBundle containing my videos, like web player, and manage those videos as I see fit. I understand the WebGLTexture was just a proof of concept, just wanted to see if there was any way to invoke ResourcesLoad (or asset bundle) and feed the video byte data to the WebGLTexture or something like that. This way, would maintain consistency in the code, between platforms.

    Nonetheless, I appreciate the response and glad to hear that there is at least something being done to address this issue eventually.
     
  34. _HAL_9000

    _HAL_9000

    Joined:
    Jun 26, 2015
    Posts:
    48
    Hello, I would like to know if it is possible to add WebglMovieTexture after compilation using WWW ? I read that WWW class has a movie variable is there something similar for webgl as movieTexture don't work in webgl ?
     
  35. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    The WebGLMovie Texture asset store package always uses a url as input source for the movie - so, yes.
     
    88er likes this.
  36. Caedriel

    Caedriel

    Joined:
    Jun 19, 2015
    Posts:
    8
    I gotta ask , are all the unity audio related classes working with the webGl movie texture ? because i am trying to mute the audio and it ain't working ..... i am sure its not my code .....
     

    Attached Files:

  37. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    WebGLMovieTexture from the asset store does not have anything to do with the AudioSource component. Pausing the video should automatically pause the audio too.
     
  38. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    869
    WebGLMovieTexture from the asset store doesnt work in chrome, it gives error that fastSeek is not a function, but the same WebGL code works in firefox. Anybody know how to solve?
     
  39. AMNOD

    AMNOD

    Joined:
    Oct 19, 2014
    Posts:
    13
    I'm facing a problem in Safari running on Mac. The video plays in a very buggy way.
    I'm using Unity 5.5.0x3. What could be the problem ?
     
  40. dilan-prasad

    dilan-prasad

    Joined:
    Sep 4, 2017
    Posts:
    1
    Hi,

    I am getting a blank screen when loading the same video for the second time after playing another video. It works fine for the first time but not when the same video button is clicked again after the other video.
    I'm using "pause" option to stop the video.

    Appreciate your help here.

    if (currentScene.name == ("Scenario1"))
    {
    videoPlayerMain = new WebGLMovieTexture("StreamingAssets/xxxx");
    }
    else
    {
    videoPlayerMain = new WebGLMovieTexture("StreamingAssets/xxx");
    }

    Sphere.GetComponent<MeshRenderer>().material.mainTexture = videoPlayerMain;

    videoPlayerMain.Play();
     
  41. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    687
    Why was this removed from the asset store? :mad:
     
    dog_funtom likes this.
  42. whitegreenstudios88

    whitegreenstudios88

    Joined:
    Dec 12, 2021
    Posts:
    10
    Hi, do you any new update
    webglMovieTexture ?