It is currently 22 Jun 2017, 19:29



CasparObjects a little VB.NET wrapper library

CasparCG Server, Client and development

Moderators: Macey, Jonas Hummelstrand, didikunz

CasparObjects a little VB.NET wrapper library

Postby didikunz » 30 Oct 2013, 17:13

For some time now I use my own .NET wrapper libray for CasparCG. It has not many fancy functions, but works very well for me. It can start the server if not already running, it gives back the response of the server and you can query for templates and media-files. It let you fill template variables via a list of fields. As a goody there is a grab function and a TGA writer, that can be used to render Targa files for use in a editing system.

Today a wrote a small demo programm:
Image

You find the demo and the library as VB.NET source here:
https://dl.dropboxusercontent.com/u/13685023/CasparObjects.zip
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: CasparObjects a little VB.NET wrapper library

Postby jrogo » 30 Oct 2013, 17:20

Thank you didikunz.
I'll try it.

Jesús
User avatar
jrogo
 
Posts: 11
Joined: 29 Oct 2013, 06:15
Location: Madrid, Spain

Re: CasparObjects a little VB.NET wrapper library

Postby Jonas Hummelstrand » 30 Oct 2013, 19:08

Thanks for sharing, Didi!
Jonas Hummelstrand
Independent Consultant at SuperFly.tv
Former Community Manager for CasparCG

Problems? Guide to posting Bug reports & Feature requests
User avatar
Jonas Hummelstrand
 
Posts: 2538
Joined: 21 Apr 2009, 08:07
Location: Stockholm, Sweden

Re: CasparObjects a little VB.NET wrapper library

Postby jrogo » 30 Oct 2013, 23:01

Hi Didi,

I've been trying your demo client. I like it, it shows me a lot of things I didn't know how to code. Thank you very much.

I've found what maybe is a little bug. When you read the templates folder and fill the listbox, if you have a template inside a user folder inside templates main folder, the "\" character between user folder name and template name is removed and so both names get together, and further fields seek fails. I've fixed this way:

CasparCG.vb file
Code: Select all
Public Function GetTemplateNames() As List(Of String)

      Dim lst As List(Of String) = New List(Of String)
      Dim Ret() As String = Execute("TLS").Data.Split(Microsoft.VisualBasic.vbCrLf)

      For Each s As String In Ret
         If s.Contains(Chr(&H22)) Then
                // You wrote this:
                // Dim tmpl As String = s.Substring(1, s.IndexOf(Chr(&H22), 2) - 1).Replace("\", "").Replace(Chr(&H22), "")
                //
                // And I've changed .Replace("\", "") to .Replace("\", "/")
                //
                Dim tmpl As String = s.Substring(1, s.IndexOf(Chr(&H22), 2) - 1).Replace("\", "/").Replace(Chr(&H22), "")
                lst.Add(tmpl)
         End If
      Next
      Return lst

   End Function


I'll keep testing. Thanks.
Jesús
User avatar
jrogo
 
Posts: 11
Joined: 29 Oct 2013, 06:15
Location: Madrid, Spain

Re: CasparObjects a little VB.NET wrapper library

Postby didikunz » 30 Oct 2013, 23:29

jrogo wrote:Hi Didi,

I've been trying your demo client. I like it, it shows me a lot of things I didn't know how to code. Thank you very much.

I've found what maybe is a little bug. When you read the templates folder and fill the listbox, if you have a template inside a user folder inside templates main folder, the "\" character between user folder name and template name is removed and so both names get together, and further fields seek fails. I've fixed this way:

CasparCG.vb file
Code: Select all
Public Function GetTemplateNames() As List(Of String)

      Dim lst As List(Of String) = New List(Of String)
      Dim Ret() As String = Execute("TLS").Data.Split(Microsoft.VisualBasic.vbCrLf)

      For Each s As String In Ret
         If s.Contains(Chr(&H22)) Then
                // You wrote this:
                // Dim tmpl As String = s.Substring(1, s.IndexOf(Chr(&H22), 2) - 1).Replace("\", "").Replace(Chr(&H22), "")
                //
                // And I've changed .Replace("\", "") to .Replace("\", "/")
                //
                Dim tmpl As String = s.Substring(1, s.IndexOf(Chr(&H22), 2) - 1).Replace("\", "/").Replace(Chr(&H22), "")
                lst.Add(tmpl)
         End If
      Next
      Return lst

   End Function


I'll keep testing. Thanks.
Jesús


You are right, I don't know, what for the .Replace(Chr(&H22), "") actually was for. It makes more sense the way you do it. Thank you.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: CasparObjects a little VB.NET wrapper library

Postby nibo » 06 Jul 2014, 10:34

Hi Didi Kunz

Many thanks for a great piece of code. It has made coding a new frontend for our Caspar in our SNG truck significantly easier.

Best regards and thanks
Niels
nibo
 
Posts: 26
Joined: 18 Dec 2013, 13:35

Re: CasparObjects a little VB.NET wrapper library

Postby yuskadeepak » 26 Feb 2015, 09:06

Hi Mr Didi Kunz,
Do you have a sample that shows how to send the template data fields using your library ? thanks in advance.

Regards,
yus
yuskadeepak
 
Posts: 38
Joined: 29 Mar 2011, 11:58

Re: CasparObjects a little VB.NET wrapper library

Postby didikunz » 26 Feb 2015, 17:07

yuskadeepak wrote:Hi Mr Didi Kunz,
Do you have a sample that shows how to send the template data fields using your library ? thanks in advance.

Regards,
yus


Hi yus,

don't call me "Mr Didi Kunz" :) it feels like being very old :) Didi is sufficient. I will do a updated version and a little tutorial in the next few days.

Didi
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: CasparObjects a little VB.NET wrapper library

Postby yuskadeepak » 27 Feb 2015, 08:24

Thanks Didi :). That would be great.
yuskadeepak
 
Posts: 38
Joined: 29 Mar 2011, 11:58

Re: CasparObjects a little VB.NET wrapper library

Postby didikunz » 27 Feb 2015, 16:05

There is a tutorial project in VB.NET 2010 here: https://dl.dropboxusercontent.com/u/13685023/CasparObjectsTutorial.zip it includes the CasparObjects source files.

The CasparObjects source and documentation, without tutorial, is here https://dl.dropboxusercontent.com/u/13685023/CasparObjects.zip

Hope it's useful to somebody.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: CasparObjects a little VB.NET wrapper library

Postby SteveElkington » 02 Mar 2015, 17:24

That great, very cool!
Thanks for sharing!
User avatar
SteveElkington
 
Posts: 243
Joined: 24 Mar 2014, 13:09
Location: UK

Re: CasparObjects a little VB.NET wrapper library

Postby Sylvain » 03 Dec 2015, 22:58

Hello Didi,
I am trying to use your dll and example. I have started with trying to run the CasparObject Tutorial but I get the following exeption :
'System.InvalidOperationException" on the line
Protected Overrides Sub OnCreateMainForm()
Me.MainForm = Global.CasparObjectsTutorial.frmMain <<<----
End Sub

Here is the French message :
Une exception non gérée du type 'System.InvalidOperationException' s'est produite dans System.Xml.dll
Informations supplémentaires : Il existe une erreur dans le document XML (1, 1).

As you may know I am not yet an experienced C# programmer but I try my best. I though I has done something silly.

So I have referenced you dll in my project and I have written this little piece of code (simple translation in C# of your VB.NET :
CasparCG _Caspar = new CasparCG("192.168.71.1");
try
{
_Caspar.Connect();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Impossible de se connecter à CasparCG");

}
if (_Caspar.Connected)
foreach (String lS in _Caspar.GetTemplateNames())
{
System.Diagnostics.Debug.WriteLine(lS);
MessageBox.Show("Template", "lS");
}

and guess what when I run it ?

I get the same exception on the line
CasparCG _Caspar = new CasparCG("192.168.71.1");
By the way I am sure of the IP address and there is a running CasparCG server on it.

Can you give me a clue to get further ?
Regards,
Sylvain
User avatar
Sylvain
 
Posts: 12
Joined: 10 Nov 2015, 11:43
Location: Oloron Sainte Marie, France

Re: CasparObjects a little VB.NET wrapper library

Postby didikunz » 04 Dec 2015, 00:52

The error in the XML library is a stupid idiot's (me) fault by messing around with a xml file and not doing it right. I will look into that tomorrow.

The connection error is more serious. Are you able to connect to Cadpar with the official client? Or is the firewall blocking Visual Studio?
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: CasparObjects a little VB.NET wrapper library

Postby Sylvain » 04 Dec 2015, 08:17

Hello Didi,
No I do not have any connectionError just the same one with the XML library. Yes I can get to connect with the official client.
Please let me know if you have sorted the xml librairie. I have not seen any xml is it "internal" the only new file I have referrenced in my projet to integrate the CasparObjects is a dll.
Regards,
Sylvain
User avatar
Sylvain
 
Posts: 12
Joined: 10 Nov 2015, 11:43
Location: Oloron Sainte Marie, France

Re: CasparObjects a little VB.NET wrapper library

Postby didikunz » 04 Dec 2015, 11:08

Hello Sylvain,

Can you please give this https://dl.dropboxusercontent.com/u/13685023/CasparObjectsTutorial.zip a try? I changed the setup of the CasparObjectsTutorial, so that it should work. I also added a possibility to enter a IP-Address.

Hope this does it. otherways we must setup a TeamViewer session tomorrow.
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: CasparObjects a little VB.NET wrapper library

Postby Sylvain » 04 Dec 2015, 19:17

CasparObjects tutorial now works like a charm : I can see my own templates !!!
Thanks, I am going to carry on my investiguations.
User avatar
Sylvain
 
Posts: 12
Joined: 10 Nov 2015, 11:43
Location: Oloron Sainte Marie, France

Re: CasparObjects a little VB.NET wrapper library

Postby vbMizio » 30 May 2017, 11:37

Hi guys,
I'm trying the CasparObject to send commands to a CasparCG Server, and it is working right.
I have two questions:
Can I know the name of a running template?
Just for example, I start a client, I load a template in a channel-layer and I run it.
In a second client, based on CasparObject, I would like to know the name of the running template on that cannel-layer.
Can I query the server?

Second question.
I have a running template, can I read some properties about the template?
An example to be more understandable.
I have a template with a timer. When the timer fires, I set a boolean variable (or property or.. something else) to Ture. i would like to check the value of the field to know when the timer is fired. Can I do that with CasparObject?
Thanks
vbMizio
 
Posts: 15
Joined: 24 May 2017, 11:34

Re: CasparObjects a little VB.NET wrapper library

Postby didikunz » 30 May 2017, 12:17

vbMizio wrote:Can I know the name of a running template?


No, that is not implemented. There is no AMCP command for that.

vbMizio wrote:I have a running template, can I read some properties about the template?


No, also not, as there is also no AMCP command for that.

What you can do with the library is get general informations about a template. There is a function called "GetTemplate" taht returns a template-object parsed out of the return of a INFO TEMPLATE command. It contains also the fieldnames (as long as they are properly exported in the template).

What could be a scenario where you would need that kind of informations from running templates?

A workaround would be to use a socket from inside a template and send a DATA comand to the server where the other client could qury for, but it's far from beeing an elegant solution. As said above: what would you use it for?
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: CasparObjects a little VB.NET wrapper library

Postby vbMizio » 30 May 2017, 13:11

Hi didi,
about the first question, ok, no problem.
About the secon one.
The scenario...
A crawl with some news. I start the crawl, when a crawl has finished its work, the crawl stop.
Then I would like to be able to know that the crawl is over, so I can update the crawl text and the restart.
I think I can set a timer on my client and send the new text after a bit, so I need to calculate the lenght (time) of the crawl by the lenght ( number of characters) of the text.
A second way can be write the code by AS3 to read a text file every loop, to make the template able to update itself.
vbMizio
 
Posts: 15
Joined: 24 May 2017, 11:34

Re: CasparObjects a little VB.NET wrapper library

Postby didikunz » 30 May 2017, 17:25

You could also build a crawl template, that you can send new data to it and as soon as the text runs off reload the data. So that you don't need to know when or if the crawl has finished. It could hide itself when there is no data any more, or just loop with the last data until new data arrives, As long as you give the template it's own layer you can leave it sitting there "for ever".
Didi Kunz
CasparCG Client-Programmer, Template Maker & Live CG-Operator
Media Support, CH-5722 Gränichen, Switzerland http://mediasupport.ch/
Problems? Guide to posting Bug reports & Feature requests
User avatar
didikunz
 
Posts: 3477
Joined: 10 May 2010, 09:08
Location: Aarau, Switzerland

Re: CasparObjects a little VB.NET wrapper library

Postby vbMizio » 01 Jun 2017, 07:49

Didi,
thanks for your answer.
I'll work on it.
vbMizio
 
Posts: 15
Joined: 24 May 2017, 11:34


Return to Tech and Development

Who is online

Users browsing this forum: Baidu [Spider], julusian and 6 guests