Jump to content

A simple script that demonstrates controlling Zoom Player via TCP


Recommended Posts

Pasted below is a short, simple AutoIt script that I wrote to test TCP control of Zoom Player Max (ZP) . The functions available are at this link.

May it help someone in the future.

Thank you to BrewManNH and TheSaint for their help in other threads I started. :thumbsup:

;simple AutoIt script for controlling Zoom Player via TCP

HotKeySet("{ESC}", "Terminate") ;ESC to bail out

;these will be used when I open the TCP socket
$ip = "127.0.0.1"
$port = "4769"

;start TCP service
TCPStartup()

;open TCP socket and see if it was successful
$socket = TCPConnect( $ip, $port )

If $Socket = -1 Then
      MsgBox(4096,"Error","Failed to connect to ZP via TCP on localhost at port 4769.")
      Terminate()
EndIf

;now loop, presenting Text Input prompt for user to enter a ZP function and optional parameters.
while 1

    ;text entry prompt with Cancel button
    $msg = InputBox("ZP TCP Controller","Enter text to send via TCP (default is play). Or Cancel to exit.): ", "5100 fnPlay" & @CRLF)
    if @error = 1 then Terminate()

    ;@CRLF needed at end of text to be sent!
    $msg = $msg & @CRLF

    ;the rubber meets the road here
    $send = TCPSend($socket, $msg)

WEnd

Terminate()

Func Terminate() ;process ESC key and close TCP

    TCPCloseSocket($socket)
    TCPShutdown()
    Exit 0

EndFunc

If anyone wants to add the ability to receive responses from Zoom Player I would welcome the addition.  Here's a link to a very clear explanation of communicating via TCP with ZP via Autohotkey, including receiving the info ZP sends back up the pipe.  Also, here's a link to download a neat TCP testing tool written in Delphi for the ZP community. Zoom Player is a great video player in my opinion, with inspiring depth AND incredible documentation.

 

Link to comment
Share on other sites

Very good, happy we could help, but you should get a Mod to relocate this to the Examples section, where it really belongs. :)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Very good, happy we could help, but you should get a Mod to relocate this to the Examples section, where it really belongs. :)

 

I had hoped that I could get some advice on how to add "receive" capability before making it a pure example-only post. I'll edit my post to emphasize that.

Link to comment
Share on other sites

For the moment your script is only a basic tcp client, nothing related to ZP; just to say  :rolleyes: .

Therefore if you need help you should edit the title of the topic, to avoid any confusion.

Link to comment
Share on other sites

For the moment your script is only a basic tcp client, nothing related to ZP; just to say  :rolleyes: .

Therefore if you need help you should edit the title of the topic, to avoid any confusion.

 

If Zoom Player is loaded with a video my script can by default send the Play command. The user has the option to enter other ZP functions or commands to test them.  That's more than existed previously in these or ZP's forums.

Link to comment
Share on other sites

ah. I didn't see the line because it's half truncated.

If you want to receive the resp of the command use the TCPRecv function.

$sResp = TCPRecv($socket, 1024)
If $sResp <> "" Then
    ConsoleWrite($sResp & @CrLf)
EndIf

Br, FireFox.

 

Thank you! I'll try your suggestion as soon as I finish helping a few clients.  The part about receiving I wondered about is whether the script has to wait in a loop, with a timeout, or if there's some sort of buffering available.  The demo program written in Delphi I cited in my original post inspired me to be curious about how to receive the default feedback ZP sends. In my current application I have no need to fetch any info from ZP but while I'm exploring using TCP with it I'd like to nail all the basics, and ZP can be asked for lots of information via TCP.  Thanks again, FireFox.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...