Features

MeTube (fx-metubeapp)

The bundled video app with synced TV and cinema screens, how it installs into the phone, its main settings and its exports.

#What it is

fx-metubeapp is a YouTube-style app that also plays videos on world screens: TV props, cinema screens and "fixed screens" drawn on any wall. Every viewer near a screen sees the same frame at the same time, synced from the server clock.

It comes as two resources:

  • fx-metubeapp: the app and the screens.
  • fx-metubeapp_assets: the streamed screen scaleform. It is kept apart so fx-metubeapp can be restarted freely. Do not restart fx-metubeapp_assets while players are online.

The app also runs without a phone as a tablet, opened with a command.

#Requirements

Resource Required
ox_lib Yes
oxmysql Yes
fx-metubeapp_assets Yes
fx-phone No. Without a phone the app opens as a tablet

#Installation

cfgensure ox_lib
ensure oxmysql
ensure fx-phone
ensure fx-metubeapp_assets
ensure fx-metubeapp
  • The database tables are created on first start. If the database user has no rights for that, import setup/install.sql by hand.
  • Admin permission for /tvdev and /tvscan:
cfgadd_ace group.admin fx-metubeapp.admin allow
  • Turn off other scripts that draw to the same screens. Two systems drawing to one TV make the screen flicker.

#How it registers into the phone

With Config.Phone.Resource = 'auto' the app installs into the running phone. Its FX Phone adapter calls exports['fx-phone']:AddCustomApp with Config.Phone.AppIdentifier (default fx_metube), AppName, Developer, Icon, DefaultApp and Size.

To keep the app from starting at all, set ['fx-metubeapp'] = false in Config.BundledApps. See Apps.

#Commands

Command Who What it does
/metube Everyone Opens the app without a phone, as a tablet
/kumanda Everyone Opens the remote of the closest screen. A key can be bound
/tvdev Admin Screen editor: tune a TV model, define a fixed screen
/tvscan Admin Prints nearby screens to F8

The command names are set in Config.Standalone.

#Fixed screens

For screens that are part of a room and cannot be found as an object, such as a cinema screen: /tvdev, then the fixed screens section, then mark the four corners in order (top left, top right, bottom right, bottom left) and save. The result is written to data/anchors.json and applied to everyone at once.

What you save in /tvdev goes to data/models.json and data/anchors.json and is layered over config.lua.

#Config highlights

Setting Meaning
Config.Locale tr or en
Config.Phone Phone choice, AppIdentifier, AppName, Icon, DefaultApp
Config.Standalone Tablet mode: Enabled, Command, RemoteCommand, RemoteKey, AllowWithPhone
Config.Playback.MaxQueue Queue length per screen (default 50)
Config.Playback.Autoplay Play YouTube's "up next" when a screen's queue runs out
Config.Playback.DriftTolerance Seconds a viewer may drift from the server clock before being re-seeked
Config.Playback.AllowDirectLinks, DirectLinkHosts Direct .mp4 / .webm links and the hosts they may come from. Every viewer's game loads the file, so keep the host list closed
Config.Playback.MaxDuration, BannedWords Length limit and blocked words for queued videos
Config.Control.ControlRange Distance to a screen to start or control a video
Config.Control.AllowLock, LockReleaseDistance The player who starts a video may lock the screen
Config.Control.IdleTimeout Sessions nobody watches are cleaned up after this many seconds
Config.Control.UseRoutingBucket Screens are separate per routing bucket
Config.Control.CanControl Function (source, screen, action); return false to refuse
Config.Render.MaxActive Screens playing video at once per player (default 2)
Config.Render.DuiWidth, DuiHeight Resolution of a screen's browser
Config.YouTube.SearchMode direct (no key, default) or apikey (official Data API, key in config_server.lua)
Config.YouTube.Home, Shorts Home feed rows and Shorts topics, each a search query
Config.Models, Config.Props, Config.Locations Known TV models and fixed screens shipped with the config

#Performance

From the resource's README:

  • Video plays only in isolated browser surfaces, never in the same browser as the HUD.
  • At most Config.Render.MaxActive screens play per player.
  • While a video plays there is no network traffic. Each client computes the position from the server clock. A message goes to a screen's viewers only when someone plays, pauses or seeks.
  • Every network input is rate limited per player, and search results are cached server-wide.

#Exports

All exports are client side.

Export Returns Purpose
PlayOnClosest(input, mode) ok, err Plays a link on the closest screen. mode is now (default), next or queue. Errors: no_screen, bad_media, or the session's own error
GetClosestSession() table or nil The state of what the closest screen plays
OpenApp(view) Opens the tablet. view defaults to home; remote opens the remote
CloseApp() Closes the tablet
lualocal ok, err = exports['fx-metubeapp']:PlayOnClosest('https://youtu.be/VIDEO_ID')