Cinema - Adding Soundcloud and Dailymotion

Hi,

I’ve been trying to find I way to add websites such as Soundcloud and Dailymotion to the Cinema gamemode.

I know from other threads that you need to use APIs for these services, but I don’t know how to implement them into the gamemode.

Any help would be greatly appreciated.

Cheers.

Crazy

You’re sort of SOL unless you know how to implement one of the following from this link into lua. At least for SoundCloud. As for Dailymotion, I’m not sure they have an API function for streaming their videos. I found this node.js plugin that converts JavaScript to lua, this might help with SoundCloud implementation.

PlayX has soundcloud support. This repo might help you https://github.com/ZionDevelopers/playx

Winterphoenix96 publishes all his javascript on github. It includes dailymotion: https://github.com/WinterPhoenix96/winterphoenix96.github.com/blob/master/cinema/js/theater.js

However you still need to implement the LUA part yourself.

-snip-

I’ve bookmarked the thread and some of the resources. I’ll see if I can do it next weekend. If not then it will be back to the drawing board.

Thanks for converting it man. I’ll try to find something inside that mess of code. xD. I would make a scriptfodder job, but I don’t have any money to offer so that wouldn’t work.

pfffff are you kidding me

That’s now how this works. That’s not how any of this works.

Edit: The Lua part of it is what’s known as a Cinema Service object. For example, here’s the YouTube one: https://github.com/pixeltailgames/cinema/blob/master/cinema/gamemode/modules/theater/services/sh_youtube.lua

Well that went downhill quickly.

Do I use the code Mexican provided or no? How would I create the service objects for the services I’ve specified. I have access to the API code, but I have no how to code it into lua format.

To put it bluntly, the code Mexican provided is completely and utterly worthless. You don’t implement stuff by “converting it” between languages.

To actually code a Cinema Service, you need to know both JavaScript and Lua. The Lua part of it is in the Cinema Gamemode itself, the JavaScript part of it is in theater.js, as shown above.

You should start by first implementing the SERVICE object in Lua, inside of your copy of the Cinema Gamemode’s code. You do this by making a new .lua file in


gamemode/modules/theater/services/

that follows the format of


sh_servicenamehere.lua

, just like all of the other services that already exist in there. For example,


sh_dailymotion.lua

.

It is at this point that you’ll have to reference the other services to figure out how to make the service object itself, written in the file you just created. I’m not going to go over that here, because if you look at one of the services and you have any idea what you’re doing, you’ll be able to figure it out rather easily.

Once you’re done with the service object and you’ve registered it with Cinema’s Service System, by using


theater.RegisterService

as seen in the other services, you’ll be ready to try and queue a video from that service. Assuming you’ve written your service correctly, requesting a video URL from that video service’s website will result in anything but “Invalid video request.” If nothing shows up at all, then you probably have your pattern matching wrong in your service’s


SERVICE:Match

function.

Assuming Cinema is able to get all the information it needs from the video service’s API (title, duration, etc), then you should be greeted in-game with an error on the theater screen that says “Video type not yet implemented.” If the screen doesn’t change at all/if the video didn’t queue successfully, go back and fix whatever is wrong with the SERVICE object.

Once you see that error on the theater screen, it’s time to switch to JavaScript and implement the video service in theater.js. Now, the easiest way to do this is to Create a user site repository using GitHub Pages and then download and reupload pixelTail’s GitHub Pages repository to your own. After you do this, remember to change the cinema_url ConVar in your copy of Cinema! You can do this by changing its default in


gamemode/modules/theater/sh_commands.lua

and then restarting your server.

Once you’ve done that, it’s probably a good idea to change the script link for


js/theater.min.js

to


js/theater.js

in


cinema/index.html

in your repository. We want to do this temporarily because modifying the non-minified theater.js is a lot easier than modifying the minified one.

Now you can start implementing your new video service in theater.js. I’m not going to go over how to do this part either since it should become relatively apparently how a video service there should be implemented by referencing the other ones already there.

Also it will probably be beneficial for you to run


cinema_html_filter 1

in your GMod client console while you’re working on the theater.js part, as that’ll allow the console to spit out any JavaScript errors you encounter along the way.

Good Luck!

Also apparently in-line code blocks aren’t supported on Facepunch Forums, so pardon my rather poorly formatted post.