PlayX 3 (Request for Comments)

The new 3.x branch can be found in the newtake branch:

API Documentation:
http://wiki.github.com/sk89q/playx/api-3x

API Reference:

Two missing features (that will likely be reimplemented as extensions):
[ul]
[li]Admin timeout[/li][li]Media timeout[/li][/ul]

I have not fully tested everything, so please alert me of any problems. If you desire a change to the API, then also feel free to suggest that.


Test Dark RP buyable TV: http://www.facepunch.com/showpost.php?p=23482324&postcount=17

Well, I notice that players tend to crash often when someone spawn a player and quickly plays a video right after it. It looks like a corrupted image on the screen for a couple of seconds and then GMod crashes.

Multiple PlayX players, where you can “subscribe” users to a certain player so that s/he only sees that player. This allows easy integration into RP gamemodes and other gamemodes that require a screen. Note that you can’t have two PlayX screens play at the same time for one person.

Auto-subscribe radius, which allows you to have only close users see the player. This is supposed to be for servers that just use PlayX as a side thing. The radius is not a simple distance away from the screen (doesn’t work for projectors); rather it’s a projection onto a line between the projector and the screen.

Local sound, which makes the volume lessen as you get farther away from the player. Right now this doesn’t work for Webkit, but it’s easily doable.

Veeeeeerrryyyyyyy GOOD for RP mode, when you finish you work?

Perhaps a vote system where an admin does not have to be on.

I can’t say right now.

That’s a well requested feature, but unfortunately it’s not in my immediate plans.

-snip-

It is a video player.

Understood.

gm_bass is broken I believe.

Even if it were working, I don’t think I will be implementing it in the next version anymore. The new Webkit is good; I just need to get around to writing a Flash Shoutcast player.

Gm_bass works fine I just used it with my Stream Radio. :wink:

Here a is a documentation of the dll:



BASS.StreamFileURL(url string, unknown int (use -1), callback function(channel, errorcode int)) -- opens a stream (given with url string), set an unknown int (the 2nd argument) and calls set a callback function. The callback function returns a channel if it can played else it returns nil and the errorcode returns a int it returns nil if there no errors.
channel = BASS.StreamFile(sound file string) -- Returns a channel.
BASS.SetPosition(position vector, velocity vector, angle angle, up vector) -- Set the position of player, for creating 3d would sound. 
BASS.p_PendingChannels() -- Unknown.

channel:play() -- Plays the channel.
channel:pause() -- Pauses the channel.
channel:stop() -- Stops the channel.
channel:setvolume(float) -- Set the volume.
channel:setposition(number seconds)  -- Set the playing position.
channel:set3dposition(position vector, forward vector, velocity vector) -- Set the position of the sound, for creating 3d would sound.
channel:getlength() -- Returns the length of the playing sound.
channel:getposition() -- Returns the start point of the playing sound.
channel:getplaying() -- Returns if a sound is playing.
channel:fft2048() -- Returns the spectrum table (table with 1024 floats).
channel:getlevel() -- Unknown.
channel:getrawtag(unknown int) -- Unknown.
channel:gettag(format string) -- Returns the tags formated by the given format string.


Some serverside cvar that makes a vote thing players have 5 seconds to answer or it won’t play for them would be nice.

I haven’t really looked at the API, but I will soon. We’re making a cinema for our new map so we want to make the volume 0 and stop rendering the screen when you’re not in the cinema.

I wanted to fade the volume but then I’d have to modify the API to have something like this:

[lua]
function SetVolume(volume)
playx.internal:RunJavaShit("#volume", volume * CINEMA_FADE)
end
[/lua]

Or is this already doable?

PlayX 2.x doesn’t have the API to do the sound fading that you want, but the client-side entity does have ChangeVolume() method that allows you to change the volume. This would fight with the volume cvar though.

Since everything is up to date with regards to Gmod updates again, I can start working on updating the API and adding the features I wanted for PlayX 3.

Yeah I just want to keep the users volume while still fading it out without touching the cvar.

It’ll be a really simple thing to modify. Just (volume * extra_volume) where you set the client volume in java or whatever and not the cvar. Not saying you should do it but now that I think about it, it could be useful for people wanting to fade the volume out based on distance from someplace somewhere in their gamemodes.

I should have been more specific. ChangeVolume() doesn’t touch the cvar – it only calls the JavaScript needed to change the volume. However, when the cvar is changed, it will call ChangeVolume() and override your changes. The “hacky way” until I get a new version out would be to modify ChangeVolume() to multiply by your own value.

Right now PlayX and the entity are really decoupled. I mean you could basically take the entity code alone and you would only need to make a few modifications to get it working. PlayX tells the entity what to play and how to play something by passing an intermediary “result” object that contains the HTML, CSS, JavaScript, and anything else needed – volume change JS included. This object is independent of PlayX and the entity.

The new 3.x branch can be found in the newtake branch:

API Documentation:
http://wiki.github.com/sk89q/playx/api-3x

API Reference:

Two missing features (that will likely be reimplemented as extensions):
[ul]
[li]Admin timeout[/li][li]Media timeout[/li][/ul]

I have not fully tested everything, so please alert me of any problems. If you desire a change to the API, then also feel free to suggest that.

I made a basic Dark RP TV to test the API:

(It’s an entity.)


AddEntity("PlayX TV", "playx_tv", "models/props/cs_office/tv_plasma.mdl", 1000, 1, "/buytv")

[ul]
[li]Buy from the F4 menu.[/li][li]Use the tool menu to control the TV (like normal).[/li][li]Sound will fade with distance.[/li][li]The TV will stop for you if you get more than 2000 units away.[/li][li]Only the owner of the TV gets automatically subscribed initially.[/li][li]Press use on the TV to toggle it on for you.[/li][li]Admins control the closest TV.[/li][/ul]

Newtake branch required.

PlayX doesnt work with DarkRP
It nulls the salary, wallet and job. Everything is empty.

With 2.5? Any Lua errors?

I know 2.2 worked with DarkRP and I know 3.0 does (just tested that).

Okay, DarkRP issue fixed :C