123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- /*
- * Copyright (C) 2014 iZc <nplusc.de>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- package de.nplusc.izc.izstreamer;
- import com.sun.jna.Memory;
- import java.awt.Canvas;
- import java.awt.Desktop;
- import java.io.IOException;
- import java.net.URI;
- import java.net.URISyntaxException;
- import javafx.application.Application;
- import javax.swing.JPanel;
- import uk.co.caprica.vlcj.player.direct.BufferFormat;
- import uk.co.caprica.vlcj.player.direct.DirectMediaPlayer;
- /**
- *
- * @author LH
- */
- public class Player extends javax.swing.JFrame implements PlayerStructure
- {
- /**
- * Creates new form Player
- * @param g refers to controller
- */
- public Player(StreamGUI g)
- {
- playmanager=g;
- initComponents();
- setResizable(false);
- }
- //public static final String StreamTitle = "";
- private StreamGUI playmanager;
- /**
- * This method is called from within the constructor to
- * initialize the form.
- * WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
- private void initComponents()
- {
- sliderVolume = new javax.swing.JSlider();
- lblSender = new javax.swing.JLabel();
- lblTIT = new javax.swing.JLabel();
- btnPlay = new javax.swing.JButton();
- Info = new javax.swing.JButton();
- btnLastPlayed = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- sliderVolume.setMajorTickSpacing(10);
- sliderVolume.setValue(100);
- sliderVolume.addMouseMotionListener(new java.awt.event.MouseMotionAdapter()
- {
- public void mouseDragged(java.awt.event.MouseEvent evt)
- {
- sliderVolumeMouseDragged(evt);
- }
- });
- lblSender.setText("Sender");
- lblTIT.setText("Now Playing:");
- btnPlay.setText("PLAY");
- btnPlay.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(java.awt.event.ActionEvent evt)
- {
- btnPlayActionPerformed(evt);
- }
- });
- Info.setText("Info");
- Info.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(java.awt.event.ActionEvent evt)
- {
- InfoActionPerformed(evt);
- }
- });
- btnLastPlayed.setText("Last 20 Tracks");
- btnLastPlayed.addActionListener(new java.awt.event.ActionListener()
- {
- public void actionPerformed(java.awt.event.ActionEvent evt)
- {
- btnLastPlayedActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(lblSender, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGap(18, 18, 18)
- .addComponent(sliderVolume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGroup(layout.createSequentialGroup()
- .addComponent(lblTIT, javax.swing.GroupLayout.PREFERRED_SIZE, 397, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(0, 8, Short.MAX_VALUE))
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addComponent(btnPlay, javax.swing.GroupLayout.PREFERRED_SIZE, 262, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
- .addComponent(Info, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(btnLastPlayed, javax.swing.GroupLayout.DEFAULT_SIZE, 114, Short.MAX_VALUE))))
- .addContainerGap())
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addContainerGap()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(lblSender)
- .addComponent(sliderVolume, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(18, 18, 18)
- .addComponent(lblTIT)
- .addGap(18, 18, 18)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addComponent(Info)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(btnLastPlayed)
- .addGap(0, 0, Short.MAX_VALUE))
- .addComponent(btnPlay, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap())
- );
- pack();
- }// </editor-fold>//GEN-END:initComponents
- public void updateSender(String s)
- {
- lblSender.setText(s);
- }
-
- private boolean isPlaying = false;
- private void btnPlayActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPlayActionPerformed
- {//GEN-HEADEREND:event_btnPlayActionPerformed
- if(isPlaying)
- {
- playmanager.stopPlay=true;
- isPlaying=false;
- btnPlay.setText("PLAY");
- }
- else
- {
-
- btnPlay.setText("STOP");
- lblSender.setText("Connecting....");
- new Thread(()->
- playmanager.play()).start();
- //http://31.7.177.108:2299/played.html
- isPlaying=true;
- }
- }//GEN-LAST:event_btnPlayActionPerformed
- private void sliderVolumeMouseDragged(java.awt.event.MouseEvent evt)//GEN-FIRST:event_sliderVolumeMouseDragged
- {//GEN-HEADEREND:event_sliderVolumeMouseDragged
- playmanager.m.setVolume(sliderVolume.getValue());
- }//GEN-LAST:event_sliderVolumeMouseDragged
- private void InfoActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_InfoActionPerformed
- {//GEN-HEADEREND:event_InfoActionPerformed
-
- }//GEN-LAST:event_InfoActionPerformed
- private void btnLastPlayedActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnLastPlayedActionPerformed
- {//GEN-HEADEREND:event_btnLastPlayedActionPerformed
- try
- {
- Desktop.getDesktop().browse(new URI("http://31.7.177.108:2294/played.html"));
- }
- catch (URISyntaxException ex)
- {
- ex.printStackTrace();
- }
- catch (IOException ex)
- {
- ex.printStackTrace();
- }
- }//GEN-LAST:event_btnLastPlayedActionPerformed
-
- public void setPlaying(String tit)
- {
- lblTIT.setText("Now playing: "+tit);
- }
- @Override
- public Canvas getBackGround()
- {
- return null;
- }
-
-
-
- /**
- * @param args the command line arguments
- */
- public static void main(String args[])
- {
-
-
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
- * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
- */
- try
- {
- for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels())
- {
- if ("Nimbus".equals(info.getName()))
- {
- javax.swing.UIManager.setLookAndFeel(info.getClassName());
- break;
- }
- }
- }
- catch (ClassNotFoundException ex)
- {
- java.util.logging.Logger.getLogger(Player.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- catch (InstantiationException ex)
- {
- java.util.logging.Logger.getLogger(Player.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- catch (IllegalAccessException ex)
- {
- java.util.logging.Logger.getLogger(Player.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- catch (javax.swing.UnsupportedLookAndFeelException ex)
- {
- java.util.logging.Logger.getLogger(Player.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable()
- {
- public void run()
- {
- VisualizedGUI vgui = new VisualizedGUI();
- //vgui.setSize(iZstreamer.width, iZstreamer.height);
- vgui.validate();
- vgui.setVisible(true);
- //StreamGUI.player.play();
- //StreamGUI.player.setPlayerStructure(vgui);
- }
- });
- }
-
-
- // Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton Info;
- private javax.swing.JButton btnLastPlayed;
- private javax.swing.JButton btnPlay;
- private javax.swing.JLabel lblSender;
- private javax.swing.JLabel lblTIT;
- private javax.swing.JSlider sliderVolume;
- // End of variables declaration//GEN-END:variables
- }
|