Server-side Module gmod_playx

Function Summary

BeginMedia(handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)
This directly processes media given as a handler.
CloseMedia()
Safe method of ending the media.
GetProjectedDistance(pos)
Gets the closet distance between a point and this instance.
GetProjectionPos()
Gets the projector's screen position, or if it's not a projector, a psuedo projection line endpoint.
GetSourcePos()
Returns the center position of the player, not necessarily where the screen is, in the case of non-projectors.
GetSubscribers()
Gets a list of Player objects.
IsSubscribed(ply)
Returns true if the passed player has subscribed to this instance.
MediaBegan(handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)
Function for overriding.
MediaBegin(handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)
Function for overriding.
MediaEnd()
Function for overriding.
MediaEnded()
Function for overriding.
MediaExpire()
Overridable function that is called on media expiration.
MediaOpen(provider, uri, start, forceLowFramerate, useJW, result)
Function for overriding.
MetadataReceive(existingMedia, newData)
Overridable function that works the same as the hook.
OpenMedia(provider, uri, start, forceLowFramerate, useJW)
Plays something as if you had typed it in the tool panel.
RaceProtectionTriggered()
Returns true if race protection is still wearing off.
ShouldAutoSubscribe(ply)
Returns true if the user should be automatically subscribed to the instance.
Subscribe(ply)
Add a user to this player's subscription list.
Unsubscribe(ply)
Remove the user from this player's subscription list.
UpdateMetadata(data)
Updates the current media metadata.

Functions

BeginMedia

gmod_playx:BeginMedia(handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)

This directly processes media given as a handler. Use OpenMedia() if you want provider detection. Use PlayX.ResolveProvider() if you want to do provider detection manually. Remember that if you want metadata later on, you will have to manually supply this entity with it, as BeginMedia() does not do that (OpenMedia() does, but because it polls the provider framework).

Parameters:

  • handler
  • uri
  • start
  • resumeSupported
  • lowFramerate
  • handlerArgs - Arguments for the handler, can be nil
  • length - Length of the media in seconds, can be nil

CloseMedia

gmod_playx:CloseMedia()

Safe method of ending the media. This can be called even if nothing is being played at the moment.


GetProjectedDistance

gmod_playx:GetProjectedDistance(pos)

Gets the closet distance between a point and this instance. This returns the distance to the point projected onto the finite line segment between self:GetSourcePos() and self:GetProjectionPos().

Parameters:

  • pos - Position

Return value:

  • Distance

GetProjectionPos

gmod_playx:GetProjectionPos()

Gets the projector's screen position, or if it's not a projector, a psuedo projection line endpoint. If the entity is not a projector then nil will be returned.

Return values:

  1. Position
  2. Normal
  3. Boolean indicating whether a screen is showing

GetSourcePos

gmod_playx:GetSourcePos()

Returns the center position of the player, not necessarily where the screen is, in the case of non-projectors.

Return values:

  1. Position
  2. Normal

GetSubscribers

gmod_playx:GetSubscribers()

Gets a list of Player objects.

Return value:

  • Table of subscribers

IsSubscribed

gmod_playx:IsSubscribed(ply)

Returns true if the passed player has subscribed to this instance.

Parameters:

  • ply

Return value:

  • Boolean

MediaBegan

gmod_playx:MediaBegan(handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)

Function for overriding. Called after media has begun.

Parameters:

  • handler
  • uri
  • start
  • resumeSupported
  • lowFramerate
  • handlerArgs - Arguments for the handler, can be nil
  • length - Length of the media in seconds, can be nil

MediaBegin

gmod_playx:MediaBegin(handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)

Function for overriding. Called after media has begun.

Parameters:

  • handler
  • uri
  • start
  • resumeSupported
  • lowFramerate
  • handlerArgs - Arguments for the handler, can be nil
  • length - Length of the media in seconds, can be nil

Return value:

  • False to deny

MediaEnd

gmod_playx:MediaEnd()

Function for overriding. Called like PlayXMediaEnd after PlayXMediaEnd.

Return value:

  • False to deny

MediaEnded

gmod_playx:MediaEnded()

Function for overriding. Called after media has ended.


MediaExpire

gmod_playx:MediaExpire()

Overridable function that is called on media expiration. See the MediaExpire hook for more information.


MediaOpen

gmod_playx:MediaOpen(provider, uri, start, forceLowFramerate, useJW, result)

Function for overriding. Called like the PlayXMediaOpen hook. Overriding this function will not call the hook unless you call BaseClass.

Parameters:

  • provider - Name of provider (detected or provided, but it will exist)
  • 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
  • result - Handler information

Return value:

  • False to deny, table to override

MetadataReceive

gmod_playx:MetadataReceive(existingMedia, newData)

Overridable function that works the same as the hook.

Parameters:

  • existingMedia - Also accessible as self.Media
  • newData - Incoming data

Return value:

  • Nil or the new data

OpenMedia

gmod_playx:OpenMedia(provider, uri, start, forceLowFramerate, useJW)

Plays something as if you had typed it in the tool panel. It will attempt to guess the handler frrom the provided provider and URI. If you've already got a handler to play, look into BeginMedia(). You can manually detect providers using the PlayX.ResolveProvider() API function.

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 values:

  1. The result generated by a provider or nil
  2. Error message if error

RaceProtectionTriggered

gmod_playx:RaceProtectionTriggered()

Returns true if race protection is still wearing off. return Boolean


ShouldAutoSubscribe

gmod_playx:ShouldAutoSubscribe(ply)

Returns true if the user should be automatically subscribed to the instance. By default this returns true, but you can override the behavior by defining a hook called PlayXShouldAutoSubscribe or by overriding the function on this entity (or derived entity class). You can manually subscribe and unsubscribe users without having this function matching. This function is only called when a PlayX entity is created and when a player joins but it is never called to "check" subscriptions.

Parameters:

  • ply

Return value:

  • False to deny

Subscribe

gmod_playx:Subscribe(ply)

Add a user to this player's subscription list. The user will start seeing the media if something is already playing. If the player is already subscribed, nothing will happen.

Parameters:

  • ply

Return value:

  • False if the player was already subscribed

Unsubscribe

gmod_playx:Unsubscribe(ply)

Remove the user from this player's subscription list. The media will stop for the player. If the player was not subscribed, then nothing will happen.

Parameters:

  • ply

Return value:

  • False if the player was not subscribed to begin with

UpdateMetadata

gmod_playx:UpdateMetadata(data)

Updates the current media metadata. Calling this while nothing is playing has no effect. This can be called many times and multiple times.

Parameters:

  • data - Metadata structure