예제 #1
0
파일: GuiClient.java 프로젝트: x-mel/eva
  // we define the method for getting a video link when pressing enter
  public String getvidlink() {
    try {
      System.setSecurityManager(new SecurityManager());

      ipadd = tfIP.getText();
      Interface client = (Interface) Naming.lookup("rmi://" + ipadd + "/getvid");

      // Get the String entered into the TextField tfInput, convert to int
      link = tfInput.getText();
      vlink = client.getvid(link);

    } catch (Exception e) {
      System.out.println("[System] Server failed: " + e);
    }
    return vlink;
  }
예제 #2
0
파일: GuiClient.java 프로젝트: x-mel/eva
  // we define the method for downloading when pressing on the download button
  public void qrvidlink() {
    try {
      System.setSecurityManager(new SecurityManager());

      ipadd = tfIP.getText();
      Interface client = (Interface) Naming.lookup("rmi://" + ipadd + "/getvid");

      // Get the String entered into the TextField tfInput, convert to int
      link = tfInput.getText();
      vlink = client.getvid(link);

      // here we receive the image serialized into bytes from the server and
      // saved it on the client as png image
      byte[] bytimg = client.qrvid(vlink);
      BufferedImage img = ImageIO.read(new ByteArrayInputStream(bytimg));
      File outputfile = new File("qrcode.png");
      ImageIO.write(img, "png", outputfile);

      // img= new ImageIcon(bytimg.toByteArray());
    } catch (Exception e) {
      System.out.println("[System] Server failed: " + e);
    }
  }
예제 #3
0
파일: GuiClient.java 프로젝트: x-mel/eva
  public GuiClient() {
    setLayout(new FlowLayout());

    /** ** We define the textfields and buttons****** */
    lbIP = new Label("Enter the IP address of the server: "); // Construct Label
    add(lbIP);

    tfIP = new TextField(110); // Construct TextField
    add(tfIP); // "super" Frame adds TextField
    tfIP.setText("10.16.31.163"); // Set a default value

    tfIP.addActionListener(this);
    // Hitting Enter on TextField fires ActionEvent
    // tfInput (TextField) registers this instance as ActionEvent listener

    lblInput = new Label("Enter a link below: ");
    add(lblInput);

    tfInput = new TextField(110);
    add(tfInput);
    tfInput.setText("http://vodlocker.com/budq9rt5wt0e");
    tfInput.addActionListener(this);

    lblOutput = new Label("The download link is below: ");
    add(lblOutput);

    tfOutput = new TextField(110);
    tfOutput.setEditable(false); // read-only
    add(tfOutput);

    /** ************Stream************** */
    Butstr = new Button("Stream"); // construct Button
    add(Butstr); // "super" Frame adds Button

    Butstr.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            streamvidlink(getvidlink());
            tfOutput.setText("The video is being streamed");
          }
        });

    /** ************Download************** */
    Butdow = new Button("Download");
    add(Butdow);

    Butdow.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            downvidlink(getvidlink());
            tfOutput.setText("The video is being downloaded");
          }
        });

    /** ************QR CODE************** */
    Butqr = new Button("Qr Code");
    add(Butqr);

    Butqr.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // we load the qrvidlink() function that saves the image locally
            qrvidlink();
            try {
              // we display the image that is saved
              Runtime.getRuntime().exec("display qrcode.png");
              tfOutput.setText("The Qr code will be generated");
            } catch (Exception ex) {
              System.out.println("Qr Code failed: " + ex);
            }
          }
        });

    setTitle("Client"); // "super" Frame sets title
    setSize(900, 400); // "super" Frame sets initial window size
    setVisible(true); // "super" Frame shows
  }
예제 #4
0
파일: GuiClient.java 프로젝트: x-mel/eva
 /** **************************************************************** */
 @Override
 public void actionPerformed(ActionEvent evt) {
   vlink = getvidlink(); // it gets the video link from the text input
   tfOutput.setText(vlink); // and tries to set the direct link to the video
 }