Class VideoAsset

java.lang.Object
net.risingworld.api.assets.Asset
net.risingworld.api.assets.VideoAsset

public final class VideoAsset extends Asset
Represents a video which can be played on a UIVideo element. Videos are always streamed by the client directly from an URL (progressive download over http/https), they are never transferred through the server. This means the URL must be reachable by every client.

Supported formats depend on the client platform (the game relies on the video decoders of the operating system):
  • Windows: H.264 (MP4/MOV), VP8/VP9 (WebM). HEVC requires the HEVC extension from the Microsoft Store.
  • macOS: H.264/HEVC (MP4/MOV). WebM is not supported.
  • Linux: VP8/VP9 (WebM) only. H.264 is not supported.
Recommendation: Provide an MP4/H.264 version as primary format and a WebM/VP8 version as fallback for Linux clients. Adaptive streaming or video platforms like YouTube are not supported.

Streaming notes: Videos are never loaded completely into memory, the client streams and decodes them on the fly, so the file length does not matter (only the resolution affects memory usage). Keep in mind:
  • The web server should support HTTP range requests, otherwise seeking (UIVideo.seek(float)) forces the client to reload the file from the beginning!
  • MP4 files should have their metadata at the beginning of the file, otherwise the client has to read the end of the file before the first frame is shown.
  • The client does not cache videos on disk: Every time playback starts after a stop (or the element is created again), the video is streamed again from the URL.
  • The URL must be accessible without a browser: Hosts with bot protection, login walls or redirects to HTML pages reject the video decoder, resulting in an access denied error on all clients.
See Also:
  • Method Details

    • loadFromURL

      public static VideoAsset loadFromURL(String url)
      Creates a video asset which references a video file located at an URL. The client streams the video directly from this URL, so it must be reachable by all clients.
      Parameters:
      url - the URL of the video file (http or https), or a route on the webserver of the game server (starting with "/").
      Returns:
      a new VideoAsset, or an existing one if this URL was already loaded before.