Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
Implemented fullscreen and removed some clutter
Browse files Browse the repository at this point in the history
  • Loading branch information
ajchili committed Jun 25, 2017
1 parent 54419ac commit d9c1d06
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 18 deletions.
5 changes: 0 additions & 5 deletions sync/src/com/kirinpatel/gui/ControlPanel.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.kirinpatel.gui;

import com.kirinpatel.Main;
import com.kirinpatel.net.Client;
import com.kirinpatel.net.Server;
import com.kirinpatel.util.Debug;
Expand All @@ -14,10 +13,6 @@
import java.io.File;
import java.util.ArrayList;

/**
* @author Kirin Patel
* @date 6/21/17
*/
public class ControlPanel extends JPanel {

private JList connectedClients;
Expand Down
81 changes: 74 additions & 7 deletions sync/src/com/kirinpatel/gui/PlaybackPanel.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.kirinpatel.gui;

import com.kirinpatel.Main;
import com.kirinpatel.vlc.MediaPlayer;
import uk.co.caprica.vlcj.discovery.NativeDiscovery;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/**
* @author Kirin Patel
* @date 6/23/17
*/
public class PlaybackPanel extends JPanel {

public static MediaPlayer mediaPlayer;
Expand All @@ -19,6 +17,8 @@ public class PlaybackPanel extends JPanel {
public JSlider mediaPosition;
public JSlider mediaVolume;
public final int type;
private JFrame fullscreen;
private boolean isFullscreen = false;

public PlaybackPanel(int type) {
super(new BorderLayout());
Expand All @@ -35,10 +35,67 @@ private void initMediaPlayer() {
initControls();
}

public void initFullscreen() {
fullscreen = new JFrame();
fullscreen.setSize(Toolkit.getDefaultToolkit().getScreenSize());
fullscreen.setUndecorated(true);
fullscreen.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {

}

@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == 32 && type == 0) {
if(mediaPlayer.isPaused()) mediaPlayer.play();
else mediaPlayer.pause();
} else if (e.getKeyCode() == 122 || e.getKeyCode() == 27) {
fullscreen.hide();
}
}

@Override
public void keyReleased(KeyEvent e) {

}
});
fullscreen.addComponentListener(new ComponentListener() {
@Override
public void componentResized(ComponentEvent e) {

}

@Override
public void componentMoved(ComponentEvent e) {

}

@Override
public void componentShown(ComponentEvent e) {

}

@Override
public void componentHidden(ComponentEvent e) {
closeFullscreen();
}
});
remove(mediaPlayer);
fullscreen.add(mediaPlayer);
fullscreen.setVisible(true);
}

public void closeFullscreen() {
fullscreen.remove(mediaPlayer);
fullscreen.dispose();
add(mediaPlayer, BorderLayout.CENTER);
}

private void initControls() {
Color foreground = Color.white;
Color background = Color.black;
JPanel controlPanel = new JPanel(new GridLayout(1, 3, 10, 0));
JPanel controlPanel = new JPanel(new GridLayout(1, 4, 10, 0));
controlPanel.setBackground(background);

pauseMedia = new JButton("");
Expand All @@ -48,6 +105,16 @@ private void initControls() {
pauseMedia.setForeground(foreground);
controlPanel.add(pauseMedia);

JButton fullscreen = new JButton("Fullscreen");
fullscreen.setBorder(null);
fullscreen.setBackground(background);
fullscreen.setForeground(foreground);
fullscreen.addActionListener(e -> {
if (!isFullscreen) initFullscreen();
});
controlPanel.add(fullscreen);


JPanel positionPanel = new JPanel(new BorderLayout());
positionPanel.setBackground(background);
mediaPositionLabel = new JLabel("0:0:00 / 0:0:00");
Expand Down
4 changes: 0 additions & 4 deletions sync/src/com/kirinpatel/tomcat/TomcatServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

import java.io.File;

/**
* @author Kirin Patel
* @date 6/23/17
*/
public class TomcatServer {

private Tomcat tomcat;
Expand Down
2 changes: 0 additions & 2 deletions sync/src/com/kirinpatel/vlc/MediaPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import java.awt.geom.AffineTransform;
import java.awt.image.*;

/**
*/
public class MediaPlayer extends JPanel {

private final PlaybackPanel playbackPanel;
Expand Down

0 comments on commit d9c1d06

Please sign in to comment.