I can render a video in a Unity texture, but is there a way to overlay a subtitle? I mean the track element.
This is very interesting, did not know that web video player even supported subtitles!
You can try directly editing the Video.js file from Unity WebGL platform directory, and there you can programmatically do
var track = document.createElement('track');
track.src = 'media/examples/friday.vtt';
video.appendChild(track);
inside the function “JS_Video_Create” in order to append the video track to the loaded video. Hopefully WebGL gl.texImage2D() upload path also uploads those text tracks, theoretically it should.
If you then need to decouple the code so that it works with stock Video.js unmodified, you can separate the code to a .jslib file, and from there, access the “$videoInstances” object directly. That way your code should work also on other people’s Unity installations unmodified.
@jukka_j I tried this before and it didn’t work. I will try it again just to make sure and get back to you.
@jukka_j Yea, I couldn’t get it to work. The subtitles show up on the html side, but they are not rendered in Unity, only the video itself.
Bummer ![]()
If you try following this tutorial Animating textures in WebGL - Web APIs | MDN for pure JavaScript/web-specific means to get it working, I wonder if that works? If so, then it suggests something is limiting it from just working in Unity.
If not, then it suggests that the video to WebGL texture paths in browsers do not take subtitles into account. In that case, we could raise a bug report against Chrome, Firefox and Safari if they would be able to fix it.