LiveCode and Caspar CG

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Tuck
Posts: 8
Joined: Thu Jul 28, 2016 1:02 pm

LiveCode and Caspar CG

Post by Tuck » Thu Jul 28, 2016 1:06 pm

Hey guy's, hope every one is well.

I am brand new to LiveCode, and to programming in general, i have a little experience with trying to teach my selfs bit though out the years and fixing things, but i am looking at building a client for CasparCG (Mac based client) then also opening it up to control other software, kinda like a hub i guess is the idea. I was wondering if any one could point me in a good starting point? Any thing that goes though getting LiveCode talking to the server?

Many thanks

Tuck

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: LiveCode and Caspar CG

Post by Da_Elf » Thu Jul 28, 2016 7:26 pm

i use livecode and casparCG all the time. Currently working on a new interface for a tv show. what sort of directions do you need to be pointed?

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: LiveCode and Caspar CG

Post by mwieder » Thu Jul 28, 2016 8:18 pm

Heh. I was gonna jump in here, but Da_Elf beat me to it.

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: LiveCode and Caspar CG

Post by Da_Elf » Thu Jul 28, 2016 9:20 pm

the more the merrier

Tuck
Posts: 8
Joined: Thu Jul 28, 2016 1:02 pm

Re: LiveCode and Caspar CG

Post by Tuck » Thu Jul 28, 2016 11:22 pm

Hey guys, thanks for getting back!!

Oh great! Just some basic's, i pick things up quite quickly but some starting blocks. How to get my app to talk to the server, retrieving info from the server. I have had a look but couldn't find any walk though's or how-to's, but I'm going to get started with the basic LiveCode pages first too. I was looking for a basic livecode stack that i could take a look in and see how its been built!

Any pointers would be great!

Cheers

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: LiveCode and Caspar CG

Post by Da_Elf » Sat Jul 30, 2016 5:50 am

you need to open a socket to caspar then you can write commands to that socket. i will strip out something when i get a chance this weekend

Tuck
Posts: 8
Joined: Thu Jul 28, 2016 1:02 pm

Re: LiveCode and Caspar CG

Post by Tuck » Tue Aug 02, 2016 1:05 pm

Afternoon @Da_Elf

I have managed to build an app that looks in a directory and lists the video files, there is then a preview monitor in the app to check the clip, and also a live monitor for showing watch it being played out. This all works fine, now to make it talk to Caspar;

I have managed to get the app to connect to the server, with a connect button and inout field to supply the IP. I see the connection on the server thats all great. Next i need the file list to retrieve from the servers media file. Before i was just setting the defaultfolder to the local location of some video clips. Now i need it to look at an external directory. I have some code looking like this;

Code: Select all

put field "Server" into HomeFolder
set the defaultfolder to Homefolder & "/CasparCG/media/"
I have already defined Server as the input IP that we are connecting to, and then i know that the servers that we will use, the media folders will be at /CasparCG/media/ so my hope would be that they would allow the app to look in this folder. But i know i am missing some bits. but being a noob i, no too sure what. What pre-fix would i need to put on the server ip to allow LiveCode to access and view the folders, or is there a Caspar command that will retrieve the file names?

When sending play, stop, load commands to Caspar do you have to open the socket eat time? So each button press would open the socket? Or is the one connection at the beginning of the sessions enough?

Also i have been searching for a little bit online but can't fined any thing, i would like my client to show the timecode of the playing clip, is this some thing that i would build in the client? maybe it finds all the frames in the video and then counts down once play has started, or could that data be graded from the server?

Many thanks
Tuck

Tuck
Posts: 8
Joined: Thu Jul 28, 2016 1:02 pm

Re: LiveCode and Caspar CG

Post by Tuck » Tue Aug 02, 2016 9:34 pm

Hey

I have been playing around all day, and have the app talking to the server. I can retrieve the list of files in the media directory but it comes back with the file name as well as size, format and the such, how can i take just the name string from the data? then when i select the name it will assign it to a vhariabule and can be used to load into the server. But i am having trouble finding out how to take only the name string from each file.

Another problem i am having is getting the preview players to register the location of the video file on the server. How can i set the directory to the server?

Many thanks

Tuck

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: LiveCode and Caspar CG

Post by Klaus » Tue Aug 02, 2016 10:02 pm

Hi Tuck,
Tuck wrote:I can retrieve the list of files in the media directory but it comes back with the file name as well as size, format and the such, how can i take just the name string from the data?
in what format are the infos coming from the server? Can you give an example?
Tuck wrote:Another problem i am having is getting the preview players to register the location of the video file on the server. How can i set the directory to the server?
You can't!

But you can create a filename to use with the player objects:

Code: Select all

...
set the filename of player "preview1" to ("http://www.your_server_com/subfolder_if_any/" & the_name_of_video)
...
Best

Klaus

Tuck
Posts: 8
Joined: Thu Jul 28, 2016 1:02 pm

Re: LiveCode and Caspar CG

Post by Tuck » Wed Aug 03, 2016 2:01 pm

Hey Klaus, thanks for getting to me!

The returned text is;

Code: Select all

200 CLS OK
"CG1080I50"  MOVIE  6159792 20141002155940 264 1/25
"CG1080I50_A"  MOVIE  10298115 20141002155940 260 1/25
"DEMO_BG_VIDEO"  MOVIE  6445960 20141002155940 268 1/25
"GO1080P25"  MOVIE  16694084 20141002155942 445 1/25
My code to retrieve it is;

Code: Select all

command uiPopulateMediaList
   #Get Clip List
   write "CLS" & format("\r\n") to socket casparServer
   if casparServer is among the lines of the opensockets then
      read from socket casparServer until empty
      put it into field "MediaList"
   end if
end uiPopulateMediaList
What i would like to do is take the first part of the data, the file name, and remove the " ". Then post just the list of names to MediaList.
So my main question is how can i save specific parts of the returned strings?

My next problem, is putting a variable into a the action;

In the line telling caspar to play the file i would like to put the variable Clip, allowing the chosen clip from the list to be loaded into the server. I have tried putting it in " ". ( ), but am not sure on this one.

Code: Select all

ommand LoadClip
   set the text of field "Clip Name 2" to Clip
   write "LOAD 1 FILENAME" & format("\r\n") to socket casparServer
   set the filename of player "Clip Live" to ("http ://" & casparServer & "/CasparCG/media/" & Clip)
end LoadClip
excuse the space int eh url, i can't post pull URL, i also have the w w w.
casparServer = Ip of server i.e. 192.168.0.2:5250

I tried your suggestion Klaus with the file location, this didn't work, i also tried simmering it just to get them talking with, putting the direct path, of the ip and directory, but this didn't work.
i have tried with and with out the port number and also with the .mov or .mp4 extensions of different files,

Where am i going wrong?


Many thanks

Tuck

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: LiveCode and Caspar CG

Post by Klaus » Wed Aug 03, 2016 3:12 pm

Hi Tuck,

at first glance, it looks like this should do the trick:

Code: Select all

ommand LoadClip
   ### set the text of field "Clip Name 2" to Clip
   put fld "Clip Name 2" into Clip
   write "LOAD 1 FILENAME" & format("\r\n") to socket casparServer
   set the filename of player "Clip Live" to ("http ://" & casparServer & "/CasparCG/media/" & Clip)

   ## You can always check THE RESULT, it should be empty on success and might give a hint otherwise:
   if the result <> EMPTY then
      answer "Error:" && the result
   end if
end LoadClip
Best

Klaus

Tuck
Posts: 8
Joined: Thu Jul 28, 2016 1:02 pm

Re: LiveCode and Caspar CG

Post by Tuck » Wed Aug 03, 2016 5:39 pm

Thanks for that Klaus,

But it isn't working, its not a web server, just another computer being used as a playout server. i don't think its actually getting the connection to the file, as when i look on the player it has to correct directory in the source field. So I'm not sure how i can get over that at the moment.

my other issue is getting where FILENAME is, to be a variable

Code: Select all

write "LOAD 1 FILENAME" & format("\r\n") to socket casparServer
Thanks for all your help! :D

Tuck

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: LiveCode and Caspar CG

Post by Klaus » Wed Aug 03, 2016 5:47 pm

Hi Tuck,
Tuck wrote:Thanks for that Klaus,

But it isn't working, its not a web server, just another computer being used as a playout server. i don't think its actually getting the connection to the file, as when i look on the player it has to correct directory in the source field. So I'm not sure how i can get over that at the moment.
hm, doesn't that "other" computer not have any address? How is it connected to your machine?
Tuck wrote:...
my other issue is getting where FILENAME is, to be a variable

Code: Select all

write "LOAD 1 FILENAME" & format("\r\n") to socket casparServer
Do you mean something like this:

Code: Select all

write "LOAD 1" && variable_holding_the_filename && format("\r\n") to socket casparServer
Best

Klaus

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: LiveCode and Caspar CG

Post by jacque » Wed Aug 03, 2016 7:12 pm

Tuck wrote:What i would like to do is take the first part of the data, the file name, and remove the " ". Then post just the list of names to MediaList.
So my main question is how can i save specific parts of the returned strings?
Two ways. You can cycle through the list in a repeat loop and extract the first word of each line:

Code: Select all

delete line 1 of tList -- the status code
repeat for each line tLine in tList
  put word 1 of tLine & cr after tNewList
end repeat
replace quote with empty in tNewList
TNewList will be a return-delimited list of names. Alternately you can convert the list to an array, and get the keys of the array, which produces the same thing:

Code: Select all

delete line 1 of tList -- the status code
split tList by cr and space
put the keys of tList into tNewList
replace quote with empty in tNewList
I think the array is slightly faster but unless the list is very, very long you won't be able to see much difference.

EDIT: revised both to remove the quotation marks from the list
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Tuck
Posts: 8
Joined: Thu Jul 28, 2016 1:02 pm

Re: LiveCode and Caspar CG

Post by Tuck » Fri Aug 05, 2016 12:22 pm

Hey Klaus,

Code: Select all

write "LOAD 1" && variable_holding_the_filename && format("\r\n") to socket casparServer
worked a treat, can't believe i didn't think of it! Im still learning :P.
Also, i played around with the access and rights on the 'Caspar Server' to see if i could get the player to talk to it, but no dice! Here are the directories of it, on the network....

A://CasparServer01/media/ - is the directory on the Caspar server, on the network it looks like it is at \\Casparserver01\a\CasparCG


- Jacque

Thank you for that, worked perfectly! Thanks you very much!!

Tuck

Post Reply