|
@@ -0,0 +1,290 @@
|
|
|
+/*
|
|
|
+ * To change this license header, choose License Headers in Project Properties.
|
|
|
+ * To change this template file, choose Tools | Templates
|
|
|
+ * and open the template in the editor.
|
|
|
+ */
|
|
|
+package de.nplusc.izc.izpl.plugins.jukebox;
|
|
|
+
|
|
|
+import de.nplusc.izc.iZpl.API.IZPLApi;
|
|
|
+import de.nplusc.izc.iZpl.API.PlaybackPlugin;
|
|
|
+import de.nplusc.izc.iZpl.API.UIPlugin;
|
|
|
+import java.awt.EventQueue;
|
|
|
+import java.awt.Image;
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ * @author tgoerner
|
|
|
+ */
|
|
|
+public class JukeBox extends javax.swing.JFrame implements UIPlugin
|
|
|
+{
|
|
|
+ private PlaybackPlugin selectedPlaybackPlugin;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates new form JukeBoxGUI
|
|
|
+ */
|
|
|
+ public JukeBox()
|
|
|
+ {
|
|
|
+ initComponents();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 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()
|
|
|
+ {
|
|
|
+
|
|
|
+ jScrollPane1 = new javax.swing.JScrollPane();
|
|
|
+ jTable1 = new javax.swing.JTable();
|
|
|
+ videoPanel = new javax.swing.JPanel();
|
|
|
+ jScrollPane2 = new javax.swing.JScrollPane();
|
|
|
+ lstScheduled = new javax.swing.JList();
|
|
|
+ jButton1 = new javax.swing.JButton();
|
|
|
+ jButton2 = new javax.swing.JButton();
|
|
|
+ btnPlayPause = new javax.swing.JButton();
|
|
|
+ btnSkip = new javax.swing.JButton();
|
|
|
+ seekBar = new javax.swing.JSlider();
|
|
|
+ lblStatus = new javax.swing.JLabel();
|
|
|
+ lblTrackName = new javax.swing.JLabel();
|
|
|
+
|
|
|
+ setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
|
+
|
|
|
+ jTable1.setModel(new javax.swing.table.DefaultTableModel(
|
|
|
+ new Object [][]
|
|
|
+ {
|
|
|
+ {null, null, null, null},
|
|
|
+ {null, null, null, null},
|
|
|
+ {null, null, null, null},
|
|
|
+ {null, null, null, null}
|
|
|
+ },
|
|
|
+ new String []
|
|
|
+ {
|
|
|
+ "ID", "Title", "# to play", "# played"
|
|
|
+ }
|
|
|
+ ));
|
|
|
+ jScrollPane1.setViewportView(jTable1);
|
|
|
+
|
|
|
+ javax.swing.GroupLayout videoPanelLayout = new javax.swing.GroupLayout(videoPanel);
|
|
|
+ videoPanel.setLayout(videoPanelLayout);
|
|
|
+ videoPanelLayout.setHorizontalGroup(
|
|
|
+ videoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGap(0, 0, Short.MAX_VALUE)
|
|
|
+ );
|
|
|
+ videoPanelLayout.setVerticalGroup(
|
|
|
+ videoPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGap(0, 268, Short.MAX_VALUE)
|
|
|
+ );
|
|
|
+
|
|
|
+ lstScheduled.setModel(new javax.swing.AbstractListModel()
|
|
|
+ {
|
|
|
+ String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
|
|
|
+ public int getSize() { return strings.length; }
|
|
|
+ public Object getElementAt(int i) { return strings[i]; }
|
|
|
+ });
|
|
|
+ jScrollPane2.setViewportView(lstScheduled);
|
|
|
+
|
|
|
+ jButton1.setText("Einreihen");
|
|
|
+
|
|
|
+ jButton2.setText("Neu laden");
|
|
|
+
|
|
|
+ btnPlayPause.setText("Play");
|
|
|
+ btnPlayPause.addActionListener(new java.awt.event.ActionListener()
|
|
|
+ {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
+ {
|
|
|
+ btnPlayPauseActionPerformed(evt);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ btnSkip.setText("Skip");
|
|
|
+ btnSkip.addActionListener(new java.awt.event.ActionListener()
|
|
|
+ {
|
|
|
+ public void actionPerformed(java.awt.event.ActionEvent evt)
|
|
|
+ {
|
|
|
+ btnSkipActionPerformed(evt);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ lblStatus.setText("--/--");
|
|
|
+
|
|
|
+ lblTrackName.setText("Track title");
|
|
|
+
|
|
|
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
|
|
+ getContentPane().setLayout(layout);
|
|
|
+ layout.setHorizontalGroup(
|
|
|
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
|
|
+ .addContainerGap()
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(videoPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(seekBar, javax.swing.GroupLayout.DEFAULT_SIZE, 374, Short.MAX_VALUE)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addComponent(btnPlayPause)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addComponent(btnSkip)
|
|
|
+ .addGap(18, 18, 18)
|
|
|
+ .addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addComponent(lblTrackName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
+ .addComponent(jScrollPane2)
|
|
|
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 486, 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, false)
|
|
|
+ .addGroup(layout.createSequentialGroup()
|
|
|
+ .addComponent(videoPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addComponent(seekBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 299, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
+ .addComponent(jButton1)
|
|
|
+ .addComponent(lblTrackName))
|
|
|
+ .addComponent(jButton2))
|
|
|
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
+ .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
+ .addComponent(btnPlayPause)
|
|
|
+ .addComponent(btnSkip)
|
|
|
+ .addComponent(lblStatus)))
|
|
|
+ .addContainerGap())
|
|
|
+ );
|
|
|
+
|
|
|
+ pack();
|
|
|
+ }// </editor-fold>//GEN-END:initComponents
|
|
|
+
|
|
|
+ private void btnSkipActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnSkipActionPerformed
|
|
|
+ {//GEN-HEADEREND:event_btnSkipActionPerformed
|
|
|
+ selectedPlaybackPlugin.skipTitle();
|
|
|
+ }//GEN-LAST:event_btnSkipActionPerformed
|
|
|
+
|
|
|
+ private void btnPlayPauseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPlayPauseActionPerformed
|
|
|
+ {//GEN-HEADEREND:event_btnPlayPauseActionPerformed
|
|
|
+ play();
|
|
|
+ }//GEN-LAST:event_btnPlayPauseActionPerformed
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getPluginName()
|
|
|
+ {
|
|
|
+ return "JukeBox";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initializePlugin()
|
|
|
+ {
|
|
|
+ selectedPlaybackPlugin=IZPLApi.getCurrentPlaybackPlugin();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void prepareUpgrade()
|
|
|
+ {
|
|
|
+ /*nothing to do for this plugin*/
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // Variables declaration - do not modify//GEN-BEGIN:variables
|
|
|
+ private javax.swing.JButton btnPlayPause;
|
|
|
+ private javax.swing.JButton btnSkip;
|
|
|
+ private javax.swing.JButton jButton1;
|
|
|
+ private javax.swing.JButton jButton2;
|
|
|
+ private javax.swing.JScrollPane jScrollPane1;
|
|
|
+ private javax.swing.JScrollPane jScrollPane2;
|
|
|
+ private javax.swing.JTable jTable1;
|
|
|
+ private javax.swing.JLabel lblStatus;
|
|
|
+ private javax.swing.JLabel lblTrackName;
|
|
|
+ private javax.swing.JList lstScheduled;
|
|
|
+ private javax.swing.JSlider seekBar;
|
|
|
+ private javax.swing.JPanel videoPanel;
|
|
|
+ // End of variables declaration//GEN-END:variables
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setAlbumArt(Image i)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private String trackTime = "--:--";
|
|
|
+ @Override
|
|
|
+ public void setTrackLength(int seconds)
|
|
|
+ {
|
|
|
+ int mins=seconds/60;
|
|
|
+ int textSeconds=seconds%60;
|
|
|
+ String textSeconds2=textSeconds>9?textSeconds+"":"0"+textSeconds;
|
|
|
+ trackTime=mins+":"+textSeconds2;
|
|
|
+ EventQueue.invokeLater(()->seekBar.setMaximum(seconds));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setPlaybackPositionInSeconds(int seconds)
|
|
|
+ {
|
|
|
+ EventQueue.invokeLater(() ->
|
|
|
+ {
|
|
|
+ int mins=seconds/60;
|
|
|
+ int textSeconds=seconds%60;
|
|
|
+ String textSeconds2=textSeconds>9?textSeconds+"":"0"+textSeconds;
|
|
|
+ lblStatus.setText(mins+":"+textSeconds2+"/"+trackTime);
|
|
|
+ seekBar.setValue(seconds);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setTrackName(String trackName)
|
|
|
+ {
|
|
|
+ EventQueue.invokeLater(()->lblTrackName.setText(trackName));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void loadPlayListEditScreen()
|
|
|
+ {
|
|
|
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initializeUI()
|
|
|
+ {
|
|
|
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private boolean connected=false;
|
|
|
+ private boolean playing=false;
|
|
|
+
|
|
|
+ private void play()
|
|
|
+ {
|
|
|
+ if(!connected)
|
|
|
+ {
|
|
|
+ selectedPlaybackPlugin.connectToPlayer();
|
|
|
+ selectedPlaybackPlugin.skipTitle();
|
|
|
+ connected=true;
|
|
|
+ }
|
|
|
+ if(playing)
|
|
|
+ {
|
|
|
+ selectedPlaybackPlugin.pause();
|
|
|
+ btnPlayPause.setText("Play");
|
|
|
+ playing=false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ selectedPlaybackPlugin.play();
|
|
|
+ btnPlayPause.setText("Pause");
|
|
|
+ playing=true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|