Client-side Module PlayX

Function Summary

static AddBookmark(title, provider, uri, keyword, startAt, lowFramerate)
Adds a new bookmark.
static Debug(msg, ...)
Prints debugging messages.
static Disable()
Disables the player.
static Enable()
Enables the player.
static GetBookmark(title)
Get a bookmark by title.
static GetBookmarkByKeyword(keyword)
Get a bookmark by keyword.
static GetCounts()
Returns counts of instances having media, having resumable media, and are playing.
static GetHandler(handler)
Gets a handler by name.
static GetInstance(ply)
Gets the player instance entity.
static GetInstances()
Gets a list of instances.
static GetVolume()
Gets the overall volume.
static HasValidHostURL()
Checks whether the host URL is valid.
static LoadBookmarks()
Load bookmarks from file.
static OpenBookmarksWindow(selectTitle)
Opens the bookmark management window.
static OpenSpawnDialog(forRepeater)
Opens the dialog for choosing a model to spawn the player with.
static OpenUpdateWindow(ver)
Opens the update window.
static PlayerExists()
Checks whether a player is spawned.
static RequestCloseMedia()
Puts in a request to close media.
static RequestOpenMedia(provider, uri, start, forceLowFramerate, useJW)
Puts in a request to open media.
static ResetRenderBounds()
Reset the render bounds of the project screen.
static ResumePlay()
Resume playing if it is not already playing.
static SaveBookmarks()
Write bookmarks to file.
static SetVolume(vol)
Sets the overall volume.
static ShowError(err)
Shows an error message.
static ShowHint(msg)
Shows a hint.
static ShowNotice()
Show the first play notice.
static StopPlay()
Hides the player and stops it.
static UpdatePanels()
Updates the tool panels.

Functions

AddBookmark

PlayX.AddBookmark(title, provider, uri, keyword, startAt, lowFramerate)

Adds a new bookmark. All fields are required.

Parameters:

  • title - How the bookmark is identified
  • provider - String or blank string
  • uri
  • keyword - Blank string for no keyword
  • startAt - Can be a time string ("3:22")
  • lowFramerate - Boolean

Return values:

  1. True for success, false otherwise
  2. Error message if error

Debug

PlayX.Debug(msg, ...)

Prints debugging messages. The cvar playx_debug must be enabled for the debug messages to show.

Parameters:

  • msg - Message
  • ... - Vars for sprintf

Disable

PlayX.Disable()

Disables the player.


Enable

PlayX.Enable()

Enables the player.


GetBookmark

PlayX.GetBookmark(title)

Get a bookmark by title.

Parameters:

  • title

Return value:

  • Bookmark object or nil

GetBookmarkByKeyword

PlayX.GetBookmarkByKeyword(keyword)

Get a bookmark by keyword.

Parameters:

  • keyword

Return value:

  • Bookmark object or nil

GetCounts

PlayX.GetCounts()

Returns counts of instances having media, having resumable media, and are playing.

Return values:

  1. Number of players that have media
  2. Number of players that are resumable
  3. Number of players that are playing

GetHandler

PlayX.GetHandler(handler)

Gets a handler by name. May return nil if the handler doesn't exist.

Parameters:

  • handler - Handler name

Return value:

  • Handler function or nil

GetInstance

PlayX.GetInstance(ply)

Gets the player instance entity. When there are multiple instances out, the behavior is undefined. A hook named PlayXSelectInstance can be defined to return a specific entity. This function may return nil.

Parameters:

  • ply - Player that can be passed to specify a user

Return value:

  • Entity or nil

GetInstances

PlayX.GetInstances()

Gets a list of instances.

Return value:

  • List of entities

GetVolume

PlayX.GetVolume()

Gets the overall volume. This is the overall volume of all players. The value will be between 0 and 100. @return


HasValidHostURL

PlayX.HasValidHostURL()

Checks whether the host URL is valid.

Return value:

  • Whether the host URL is valid

LoadBookmarks

PlayX.LoadBookmarks()

Load bookmarks from file.


OpenBookmarksWindow

PlayX.OpenBookmarksWindow(selectTitle)

Opens the bookmark management window. A bookmark title can be provided so that the bookmark is automatically selected when the window is opened.

Parameters:

  • selectTitle - Optional bookmark title to select.

OpenSpawnDialog

PlayX.OpenSpawnDialog(forRepeater)

Opens the dialog for choosing a model to spawn the player with.

Parameters:

  • forRepeater

OpenUpdateWindow

PlayX.OpenUpdateWindow(ver)

Opens the update window.

Parameters:

  • ver

PlayerExists

PlayX.PlayerExists()

Checks whether a player is spawned. @return


RequestCloseMedia

PlayX.RequestCloseMedia()

Puts in a request to close media. A request will be sent to the server for processing.


RequestOpenMedia

PlayX.RequestOpenMedia(provider, uri, start, forceLowFramerate, useJW)

Puts in a request to open media. A request will be sent to the server for processing.

Parameters:

  • provider - Name of provider, leave blank to auto-detect
  • uri - URI to play
  • start - Time to start the video at, in seconds
  • forceLowFramerate - Force the client side players to play at 1 FPS
  • useJW - True to allow the use of the JW player, false for otherwise, nil to default true

Return value:

  • The result generated by a provider, or nil and the error message

ResetRenderBounds

PlayX.ResetRenderBounds()

Reset the render bounds of the project screen.


ResumePlay

PlayX.ResumePlay()

Resume playing if it is not already playing.


SaveBookmarks

PlayX.SaveBookmarks()

Write bookmarks to file.


SetVolume

PlayX.SetVolume(vol)

Sets the overall volume. This is the overall volume of all players. The value is between 0 and 100. @return

Parameters:

  • vol

ShowError

PlayX.ShowError(err)

Shows an error message. It will be shown in a popup if it is enabled or if hints do not exist in this gamemode.

Parameters:

  • err

ShowHint

PlayX.ShowHint(msg)

Shows a hint. This only works on sandbox gamemodes and gamemodes that implement GAMEMODE.AddNotify. If AddNotify is not available, the message will not be shown anywhere.

Parameters:

  • msg

ShowNotice

PlayX.ShowNotice()

Show the first play notice. This will only show anything if hints exist in the gameode.


StopPlay

PlayX.StopPlay()

Hides the player and stops it.


UpdatePanels

PlayX.UpdatePanels()

Updates the tool panels. This calls the PlayXUpdateUI hook with no arguments and with no regards to the returned value.