Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post

    Open program and send data to it

    hey!
    So.. I wanna make a program to be executed remotely on another computer. Like i command from my computer to open a video file at my laptop and then send data to it like "Enter" key so that the window will be maximized.

    Could u guys post some documentation links step by step of what should i do?

    thanks a lot!

    ps: i tried to do this with php exec() function but it backfired n there i explained a little more about my problem hope it helps! Just exec and don't output.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Using Java's RMI would probably be the easiest approach. Here's a tutorial from oracle with the overview of the RMI methodologies and an example: http://docs.oracle.com/javase/tutorial/rmi/index.html
    You'll still need to go over the documentation of the KMPlayer with a fine tooth comb as well. It should have documented the command line functionality, and even better if you can pipe commands to a running gui through the process itself.
    The fun part is this: it may not even be this complex to perform. With many media servers nowadays they have built in RSTP servers (I think that's the protocol it uses). This means they would have a listener on a socket for the source machine which you can open to and send commands to the running RSTP directly. You'll need to check the player's docs for information about this, and learn the RSTP communication RFC as well (there should be a link on wiki to the rfc as well). Some apps like VLC also have a built in remote control interface to take this layer away, although I've never attempted to use it.
    And before you ask, if you have a running RSTP for the player, yes you could use PHP as well. Although for anything interactive especially in a local lan I'd suggest you don't use a web based language for that task.

  • Users who have thanked Fou-Lu for this post:

    sorlaker (01-12-2013)

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Fou-lu let's start with basics first pls. How do i open a video file with kmplayer? All i've seen googleing* was opening a video with default video player. So.. besides changing the system's default player how can i make kmplayer (or any other program) open a file using Java ofc

    thanks a lot!


    ps: can i use sockets instead of those java rmi?
    Last edited by sorlaker; 01-13-2013 at 01:17 AM.

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    The sockets and RMI are two different things. The RMI would use sockets, but its designed to communicate between two different machines. Think like a chat client.
    Java is quite capable of opening sockets.

    I can't tell you how to open a file with the KMPlayer, I just don't use it. VLC and Media player both accept a filename in the argument when launching it, so I presume KMPlayer would as well.

  • #5
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Fou-Lu could u tell me if java applets could do what that php exec() couldn't?

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Unless you create an RMI, than the applet would only work on the client loading it. Applets are Client side executed as opposed to PHP which is Server side. You also need to sign the applet if you intend to act with privilege on the remote machine. The applet is like HTML is to the browser.

    So yes, you can use the applet on the client, but no you cannot connect remotely to it directly like that.

  • #7
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Since i'm a noob and i was quite in a hurry i could do that basically using sockets n JFrame.

    Did that by watching chat services tutorial.
    1 side was me writing commands.
    On the other side my laptop running it.

    But i got stuck on an issue.
    I created the method showFolders(); // to receive all the folders from my laptop to my pc.

    So whats the best to to display that for me? I thought about something like buttons containing those folder names but since there are many folder i couldn't scrollable the getContentPane();

    Do you have any better idea? Or help fix solve this problem.

    What i want is like a width=500 height=400 JFrame to display buttons like :
    "Inception"
    "LimitLess"
    "Avatar"
    "Iron Man"
    scrollable since there r many titles so that i could click on one of them to be played on my laptop.

    thanks in advance

    ps (edit1) : AWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW MANNN java's gui so boring!! wish i could use css on it. :P

    ps (edit2) : Solved it simply using Sockets. thanks
    Last edited by sorlaker; 01-16-2013 at 05:38 PM.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,980
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    You sorta can use CSS, but they are hard properties in Java. You're better off using a LookAndFeel manager instead. Customizing the actual L&F is quite a bit of work in Java; its not simple like CSS and HTML is (but that's all HTML/CSS' job is, so I think that's a fair trade).
    You can see some screenshots and download links for a few themes here: http://geeknizer.com/best-java-swing...casual-top-10/

    Scrolling in Java gui is very simple. Simply add the scrollable content to a JScrollPane and add that panel to the frame instead of the large component. Without customizing a thing, the JScrollPane's job is to determine the viewport size you have and add scrollable content to it.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #9
    Regular Coder
    Join Date
    Dec 2009
    Posts
    173
    Thanks
    24
    Thanked 1 Time in 1 Post
    Fou-Lu i've found a better but painfull way to do that using using php and java sockets. It worked like a charm. Thanks for your help!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •