Is there any tutorial how to start programming client program

I have my little mediaplayer program writen in C#. It just uses Windows media player.
I would like to update it to control Caspar GC, but I´m just starting to learn programming and can not find any tutorials how to install client libraries and what libraries to use.

I found CasparCG AmcpClient and but can’t figure out how to set these libraries up so I could start experimenting with the example code.

Any help with this would be appreciated.

Basically to control CasparCG you only need a System.Net.Sockets.Socket object in dotNET and open a connection to CasparCG Server with the IP of the PC Caspar runs on (usually, the localhost) and the port 5250. If you established the connection you can start to send AMCP commands to it. These commands are UTF-8 encoded text strings.

I use my own library, written in VB.NET, in all my clients. It is not much more than a wrapper around the System.Net.Sockets.Socket object and does add only a thin object layer.

You find the source on GitHub and a very basic tutorial project here.

Thank you.
The tutorial project can not connect to caspar and it throws exeption
‘System.UriFormatException’ in System.dll

It should not :smiley: I will look at asap.

You can used my lib to connect to caspar.
But it’s a litle complex for beginer.
You can also use the Stillsoft lib more easy to use to begin. You can inspire you by regarding his code on ClientExample :wink:

I began like you 7 years laters and now I’m a professional developer. Keep coding and have fun.

1 Like

Would you mind trying this.

1 Like

I still get these exceptions and can not connect.

Exception thrown: ‘System.Net.Sockets.SocketException’ in System.dll
Exception thrown: ‘System.UriFormatException’ in System.dll
Exception thrown: ‘System.Net.Sockets.SocketException’ in System.dll
Exception thrown: ‘System.UriFormatException’ in System.dll

Do you run it from inside Visual Studio?

The tutorial project tries to connect to a CasparCG server running on the same machine, by connecting it to it on the address localhost and on the default caspar port of 5250.

Can you write ping localhost in a console window and see if you get a response? Do you have the Windows firewall enabled?

I did not noticed this before, but Tutorial still seem to work altough it says it can´t connect.
Because there are no indication it is connected, it gives the error and there are no media showing until you click the combo box I just missed that it is connected and working.

It finds media and I can load, play and stop media. So it clearly can connect to caspar, just why it says it can´t.
Is it just because the exaple code is already connected to server and it is missing error handling if user is trying to connect again and there is already an established connection?

Anyway. Thank you for your help. Now I just need to take the time to study the tutorial.

There has been an error in the btnConnect_Click routine. My fault, sorry. The corrected version is here.

Be aware, that the tutorial project only covers the basics of the basics (and has been created in a rush, that is why such errors appear). To get more knowledge go through the methods and properties found in the CasparObjects project, mostly inside the CasparCG.vb file. That is where the magic happens. The stuff is grouped in regions and most of the methods have a short explanation comment. The whole thing is not much more than a wrapper to the AMCP commands. And only the template objects are a bit more. I do all of my clients with it and find it convenient to work.

1 Like

Hello Didikunz,
I am happy to see you are still around, delivering good advice. I have tried to make your example running with no success. I think I do not have the corresponding templates.
Question 1 : Do you have specific templates for your tutorial ?
Question 2 : If I understand well you have build a : AMCP commands wrapper so you can use it for both HTML and Flash templates ? You could even have the same client using your Wrapper to address a set of HTML template or a set of flash template ?
Best regards,

Hi Sylvain,

The example is very simple. It should run with any template that has two, or more, fields with the name f0 and f1. The wrapper works for Flash and HTML. On GitHub you find a more recent version. There is a slight difference between the handling of Flash vs HTML. Therefore the Template object has a property to format for HTML. Because for instance dynamic color fields need to be formated differently. But beside that, it can work with either technology.