Search Unity

Unity WebGL Movie Texture...... muting the audio

Discussion in 'WebGL' started by nsmith1024, Oct 22, 2016.

  1. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    609
  2. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    609
    Never mind i figured it out
     
  3. Broheim

    Broheim

    Joined:
    Jun 25, 2009
    Posts:
    3
    How did you do it?
    And did you also manage to control the volume or just mute it?
     
  4. mkiio

    mkiio

    Joined:
    Jul 27, 2013
    Posts:
    4
    This is one of the top results when you search for how to do this on Google. I had to figure this out today and thought I'd share just in case someone else ended up here like me.

    To get support for volume and mute you just need to expose them through the WebGLMovieTexture.jslib and WebGLMovieTexture.cs files in the Plugins folder.

    In WebGLMovieTexture.jslib add:

    Code (JavaScript):
    1. WebGLMovieTextureMute: function(video, mute)
    2. {
    3.      videoInstances[video].muted = mute;
    4. },
    5. WebGLMovieTextureVolume: function(video, volume)
    6. {
    7.     videoInstances[video].volume = volume;
    8. }
    Somewhere in the file, and mind the "," that separates them.

    Then in WebGLMovieTexture.cs you need to add:

    Code (CSharp):
    1.  
    2.     [DllImport("__Internal")]
    3.     private static extern void WebGLMovieTextureMute (int video, bool mute);
    4.  
    5.     [DllImport("__Internal")]
    6.     private static extern void WebGLMovieTextureVolume (int video, float volume);
    7.  
    8.     private static void WebGLMovieTextureMute(int video, bool mute)
    9.     {
    10.         throw new PlatformNotSupportedException("WebGLMovieTexture is only supported on WebGL.");
    11.     }
    12.     private static void WebGLMovieTextureVolume(int video, float volume)
    13.     {
    14.         throw new PlatformNotSupportedException("WebGLMovieTexture is only supported on WebGL.");
    15.     }
    16.  
    17.  
    18.     public void Mute(bool m)
    19.     {
    20.            WebGLMovieTextureMute(m_Instance, m);
    21.     }
    22.  
    23.     public void Volume(float v)
    24.     {
    25.         WebGLMovieTextureVolume(m_Instance, v);
    26.     }
    Then you can set them by using movie.Volume(0.5f) and movie.Mute(true), where movie is your WebGLMovieTexture.

    Attached the changed files as well, be sure to remove the .js extension from the jslib file. That's just so it will upload.
     

    Attached Files:

  5. nsmith1024

    nsmith1024

    Joined:
    Mar 18, 2014
    Posts:
    609
    just saw this, yes that looks like how i did it
     
  6. natsupy

    natsupy

    Joined:
    Feb 5, 2016
    Posts:
    17
    thanks for help, can to change stereo pan sound with movie texture webgl ?
     
  7. ProfPivec

    ProfPivec

    Joined:
    Sep 21, 2012
    Posts:
    18
    WebGLMovieTexture appears to work well, thanks.

    However, the movie appears to be reflecting on other surfaces, even when refection probes are disabled.

    I am using 2017-3. Any ideas please?

    Thanks in advance