|
@@ -5,12 +5,10 @@
|
|
*/
|
|
*/
|
|
package de.nplusc.izc.izpl.plugins.jukebox;
|
|
package de.nplusc.izc.izpl.plugins.jukebox;
|
|
|
|
|
|
|
|
+import de.nplusc.izc.iZpl.API.FeaturePlugin;
|
|
import de.nplusc.izc.iZpl.API.IZPLApi;
|
|
import de.nplusc.izc.iZpl.API.IZPLApi;
|
|
-import de.nplusc.izc.iZpl.API.PlayListEditAPI;
|
|
|
|
-import de.nplusc.izc.iZpl.API.PlaybackPlugin;
|
|
|
|
import de.nplusc.izc.iZpl.API.UIPlugin;
|
|
import de.nplusc.izc.iZpl.API.UIPlugin;
|
|
import de.nplusc.izc.iZpl.API.shared.InvalidPlayListFileException;
|
|
import de.nplusc.izc.iZpl.API.shared.InvalidPlayListFileException;
|
|
-import de.nplusc.izc.iZpl.API.shared.PlayListItem;
|
|
|
|
import de.nplusc.izc.tools.baseTools.Detectors;
|
|
import de.nplusc.izc.tools.baseTools.Detectors;
|
|
import de.nplusc.izc.tools.baseTools.HidableTableColumnModel;
|
|
import de.nplusc.izc.tools.baseTools.HidableTableColumnModel;
|
|
import java.awt.Dimension;
|
|
import java.awt.Dimension;
|
|
@@ -39,9 +37,10 @@ import org.apache.logging.log4j.Logger;
|
|
*
|
|
*
|
|
* @author tgoerner
|
|
* @author tgoerner
|
|
*/
|
|
*/
|
|
-public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListener
|
|
|
|
|
|
+public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListener,FeaturePlugin,PlaybackStatusUpdater
|
|
{
|
|
{
|
|
- private PlaybackPlugin selectedPlaybackPlugin;
|
|
|
|
|
|
+
|
|
|
|
+ private Backend jukeboxBackend;
|
|
private static final Logger l = LogManager.getLogger();
|
|
private static final Logger l = LogManager.getLogger();
|
|
/**
|
|
/**
|
|
* Creates new form JukeBoxGUI
|
|
* Creates new form JukeBoxGUI
|
|
@@ -73,26 +72,25 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
lblTrackName = new javax.swing.JLabel();
|
|
lblTrackName = new javax.swing.JLabel();
|
|
|
|
|
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
|
- setPreferredSize(new java.awt.Dimension(480, 800));
|
|
|
|
|
|
|
|
tblPLE.setAutoCreateRowSorter(true);
|
|
tblPLE.setAutoCreateRowSorter(true);
|
|
tblPLE.setModel(new javax.swing.table.DefaultTableModel(
|
|
tblPLE.setModel(new javax.swing.table.DefaultTableModel(
|
|
new Object [][]
|
|
new Object [][]
|
|
{
|
|
{
|
|
- {null, null, null, null},
|
|
|
|
- {null, null, null, null},
|
|
|
|
- {null, null, null, null},
|
|
|
|
- {null, null, null, null}
|
|
|
|
|
|
+ {null, null},
|
|
|
|
+ {null, null},
|
|
|
|
+ {null, null},
|
|
|
|
+ {null, null}
|
|
},
|
|
},
|
|
new String []
|
|
new String []
|
|
{
|
|
{
|
|
- "ID", "Title", "# to play", "# played"
|
|
|
|
|
|
+ "ID", "Title"
|
|
}
|
|
}
|
|
)
|
|
)
|
|
{
|
|
{
|
|
boolean[] canEdit = new boolean []
|
|
boolean[] canEdit = new boolean []
|
|
{
|
|
{
|
|
- false, false, false, false
|
|
|
|
|
|
+ false, false
|
|
};
|
|
};
|
|
|
|
|
|
public boolean isCellEditable(int rowIndex, int columnIndex)
|
|
public boolean isCellEditable(int rowIndex, int columnIndex)
|
|
@@ -215,9 +213,9 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
}
|
|
}
|
|
if((modified&evt.ALT_MASK)!=0)
|
|
if((modified&evt.ALT_MASK)!=0)
|
|
{
|
|
{
|
|
- IZPLApi.shutdownWithSave();
|
|
|
|
|
|
+ jukeboxBackend.quitWithSave();
|
|
}
|
|
}
|
|
- selectedPlaybackPlugin.skipTitle();
|
|
|
|
|
|
+ jukeboxBackend.skip();
|
|
}//GEN-LAST:event_btnSkipActionPerformed
|
|
}//GEN-LAST:event_btnSkipActionPerformed
|
|
|
|
|
|
private void btnPlayPauseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPlayPauseActionPerformed
|
|
private void btnPlayPauseActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPlayPauseActionPerformed
|
|
@@ -232,13 +230,13 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
int index = (Integer)((DefaultTableModel)tblPLE.getModel()).getValueAt(viewRow,0);
|
|
int index = (Integer)((DefaultTableModel)tblPLE.getModel()).getValueAt(viewRow,0);
|
|
if(index>=0)
|
|
if(index>=0)
|
|
{
|
|
{
|
|
- PlayListEditAPI.forceElement(index);
|
|
|
|
|
|
+ jukeboxBackend.enqueue(index);
|
|
}
|
|
}
|
|
}//GEN-LAST:event_btnEnqueueActionPerformed
|
|
}//GEN-LAST:event_btnEnqueueActionPerformed
|
|
|
|
|
|
private void btnReloadActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnReloadActionPerformed
|
|
private void btnReloadActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnReloadActionPerformed
|
|
{//GEN-HEADEREND:event_btnReloadActionPerformed
|
|
{//GEN-HEADEREND:event_btnReloadActionPerformed
|
|
- PlayListEditAPI.reloadList();
|
|
|
|
|
|
+ jukeboxBackend.reload();
|
|
rebuildTable(false);
|
|
rebuildTable(false);
|
|
}//GEN-LAST:event_btnReloadActionPerformed
|
|
}//GEN-LAST:event_btnReloadActionPerformed
|
|
|
|
|
|
@@ -251,9 +249,16 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
@Override
|
|
@Override
|
|
public void initializePlugin()
|
|
public void initializePlugin()
|
|
{
|
|
{
|
|
- l.info("Init UI(JukeBox)");
|
|
|
|
- selectedPlaybackPlugin=IZPLApi.getCurrentPlaybackPlugin();
|
|
|
|
- l.trace(selectedPlaybackPlugin+"");
|
|
|
|
|
|
+ if(IZPLApi.getUIPlugin()==this)
|
|
|
|
+ {
|
|
|
|
+ l.info("Init UI(JukeBox)");
|
|
|
|
+ jukeboxBackend= new LocalBackend(this);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ l.info("Loaded as featurePlugin, delaying the init");
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -262,16 +267,13 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
/*nothing to do for this plugin*/
|
|
/*nothing to do for this plugin*/
|
|
}
|
|
}
|
|
|
|
|
|
- private boolean rebuilding=false;
|
|
|
|
private void rebuildTable(boolean recovery)
|
|
private void rebuildTable(boolean recovery)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
- rebuilding = true;
|
|
|
|
-
|
|
|
|
//mdl.setAllColumnsVisible();
|
|
//mdl.setAllColumnsVisible();
|
|
- PlayListEditAPI.refreshKeyList();
|
|
|
|
- String[] titles = PlayListEditAPI.getTrackTitles();
|
|
|
|
|
|
+
|
|
|
|
+ String[] titles = jukeboxBackend.getTitles();
|
|
for(int i=tblPLE.getRowCount()-1;i>0;i--)
|
|
for(int i=tblPLE.getRowCount()-1;i>0;i--)
|
|
{
|
|
{
|
|
((DefaultTableModel)tblPLE.getModel()).removeRow(i-1);
|
|
((DefaultTableModel)tblPLE.getModel()).removeRow(i-1);
|
|
@@ -280,8 +282,6 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
{
|
|
{
|
|
tblPLE.getModel().setValueAt(0,0,0);
|
|
tblPLE.getModel().setValueAt(0,0,0);
|
|
tblPLE.getModel().setValueAt(titles[0],0,1);
|
|
tblPLE.getModel().setValueAt(titles[0],0,1);
|
|
- tblPLE.getModel().setValueAt(PlayListEditAPI.getTargetPlayCount(0),0,2);
|
|
|
|
- tblPLE.getModel().setValueAt(PlayListEditAPI.getPlayCount(0),0,3);
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -295,21 +295,17 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
((DefaultTableModel)tblPLE.getModel()).addRow(new Object[]{null,null,null,null});
|
|
((DefaultTableModel)tblPLE.getModel()).addRow(new Object[]{null,null,null,null});
|
|
tblPLE.getModel().setValueAt(i,i,0);
|
|
tblPLE.getModel().setValueAt(i,i,0);
|
|
tblPLE.getModel().setValueAt(titles[i],i,1);
|
|
tblPLE.getModel().setValueAt(titles[i],i,1);
|
|
- tblPLE.getModel().setValueAt(PlayListEditAPI.getTargetPlayCount(i),i,2);
|
|
|
|
- tblPLE.getModel().setValueAt(PlayListEditAPI.getPlayCount(i),i,3);
|
|
|
|
}
|
|
}
|
|
- rebuilding=false;
|
|
|
|
}
|
|
}
|
|
catch(InvalidPlayListFileException e)
|
|
catch(InvalidPlayListFileException e)
|
|
{
|
|
{
|
|
- rebuilding=false;
|
|
|
|
if(recovery)
|
|
if(recovery)
|
|
{
|
|
{
|
|
l.error("Serious statefile corruption detected");
|
|
l.error("Serious statefile corruption detected");
|
|
- IZPLApi.quickQuitWithoutSaving();
|
|
|
|
|
|
+ IZPLApi.quickQuitWithoutSaving(); //this should not happen at all on remote
|
|
}
|
|
}
|
|
//reloading data from disk and flushing internal references when the resume state got corrupted from a encoding change
|
|
//reloading data from disk and flushing internal references when the resume state got corrupted from a encoding change
|
|
- PlayListEditAPI.reloadList();
|
|
|
|
|
|
+ jukeboxBackend.reload();
|
|
rebuildTable(recovery);
|
|
rebuildTable(recovery);
|
|
}
|
|
}
|
|
//mdl.setColumnVisible(0, false);
|
|
//mdl.setColumnVisible(0, false);
|
|
@@ -334,7 +330,8 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
{
|
|
{
|
|
if(e.getSource()==seekBar)
|
|
if(e.getSource()==seekBar)
|
|
{
|
|
{
|
|
- selectedPlaybackPlugin.seek(seekBar.getValue());
|
|
|
|
|
|
+
|
|
|
|
+ jukeboxBackend.seek(seekBar.getValue());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -343,7 +340,7 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
{
|
|
{
|
|
if(e.getSource()==seekBar)
|
|
if(e.getSource()==seekBar)
|
|
{
|
|
{
|
|
- selectedPlaybackPlugin.pause();
|
|
|
|
|
|
+ jukeboxBackend.pause();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@Override
|
|
@Override
|
|
@@ -351,9 +348,11 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
{
|
|
{
|
|
if(e.getSource()==seekBar)
|
|
if(e.getSource()==seekBar)
|
|
{
|
|
{
|
|
- selectedPlaybackPlugin.seek(seekBar.getValue());
|
|
|
|
|
|
+ jukeboxBackend.seek(seekBar.getValue());
|
|
if(playing)
|
|
if(playing)
|
|
- selectedPlaybackPlugin.play();
|
|
|
|
|
|
+ {
|
|
|
|
+ jukeboxBackend.play();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -361,7 +360,7 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
@Override
|
|
@Override
|
|
public void setAlbumArt(Image i)
|
|
public void setAlbumArt(Image i)
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ //not used for the JukeBox so far
|
|
}
|
|
}
|
|
|
|
|
|
private String trackTime = "--:--";
|
|
private String trackTime = "--:--";
|
|
@@ -429,19 +428,12 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
//END HACK
|
|
//END HACK
|
|
mdl=(HidableTableColumnModel) tblPLE.getColumnModel();
|
|
mdl=(HidableTableColumnModel) tblPLE.getColumnModel();
|
|
mdl.setColumnVisible(mdl.getColumn(0), false);
|
|
mdl.setColumnVisible(mdl.getColumn(0), false);
|
|
- //most probably "embedded" device.
|
|
|
|
- if(onARM)
|
|
|
|
- {
|
|
|
|
- //target and current playcount hidden, decluttering
|
|
|
|
- mdl.setColumnVisible(mdl.getColumn(1), false);
|
|
|
|
- mdl.setColumnVisible(mdl.getColumn(1), false);
|
|
|
|
- }
|
|
|
|
addWindowListener(new WindowAdapter()
|
|
addWindowListener(new WindowAdapter()
|
|
{
|
|
{
|
|
@Override
|
|
@Override
|
|
public void windowClosing(WindowEvent e)
|
|
public void windowClosing(WindowEvent e)
|
|
{
|
|
{
|
|
- IZPLApi.shutdownWithSave();
|
|
|
|
|
|
+ jukeboxBackend.quitWithSave();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
seekBar.addMouseListener(this);
|
|
seekBar.addMouseListener(this);
|
|
@@ -478,19 +470,18 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
{
|
|
{
|
|
if(!connected)
|
|
if(!connected)
|
|
{
|
|
{
|
|
- selectedPlaybackPlugin.connectToPlayer();
|
|
|
|
- selectedPlaybackPlugin.skipTitle();
|
|
|
|
|
|
+ jukeboxBackend.initBackend();
|
|
connected=true;
|
|
connected=true;
|
|
}
|
|
}
|
|
if(playing)
|
|
if(playing)
|
|
{
|
|
{
|
|
- selectedPlaybackPlugin.pause();
|
|
|
|
|
|
+ jukeboxBackend.pause();
|
|
btnPlayPause.setText("Play");
|
|
btnPlayPause.setText("Play");
|
|
playing=false;
|
|
playing=false;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- selectedPlaybackPlugin.play();
|
|
|
|
|
|
+ jukeboxBackend.play();
|
|
btnPlayPause.setText("Pause");
|
|
btnPlayPause.setText("Pause");
|
|
playing=true;
|
|
playing=true;
|
|
}
|
|
}
|
|
@@ -510,10 +501,10 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
public void refreshScheduledItemList()
|
|
public void refreshScheduledItemList()
|
|
{
|
|
{
|
|
EventQueue.invokeLater(()->{
|
|
EventQueue.invokeLater(()->{
|
|
- DefaultListModel<String> model = (DefaultListModel<String>) lstScheduled.getModel();
|
|
|
|
- model.clear();
|
|
|
|
- List<PlayListItem> items = PlayListEditAPI.getScheduledList();
|
|
|
|
- items.forEach((e)->{model.addElement(PlayListEditAPI.getTitle(e));});
|
|
|
|
|
|
+ DefaultListModel<String> model = (DefaultListModel<String>) lstScheduled.getModel();
|
|
|
|
+ model.clear();
|
|
|
|
+ List<String> items = jukeboxBackend.getScheduledTracks();
|
|
|
|
+ items.forEach((e)->{model.addElement(e);});
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -522,6 +513,72 @@ public class JukeBox extends javax.swing.JFrame implements UIPlugin,MouseListene
|
|
{
|
|
{
|
|
EventQueue.invokeLater(()->this.rebuildTable(false));
|
|
EventQueue.invokeLater(()->this.rebuildTable(false));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void parseParameter(String param)
|
|
|
|
+ {
|
|
|
|
+ if(param!=null&&!param.equals(""))
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean hasUserInterface()
|
|
|
|
+ {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void openUserInterface()
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean requiresLoadedPlayList()
|
|
|
|
+ {
|
|
|
|
+ return false; //not needed since it connects via Network to the Real jukebox
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //compat stub for the backend
|
|
|
|
+ @Override
|
|
|
|
+ public void updateTrackLength(int length)
|
|
|
|
+ {
|
|
|
|
+ setTrackLength(length);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void updateTrackTitle(String title)
|
|
|
|
+ {
|
|
|
|
+ setTrackName(title);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void updateCurrentPlaybackPosition(int position)
|
|
|
|
+ {
|
|
|
|
+ setPlaybackPositionInSeconds(position);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void triggerTableRefresh()
|
|
|
|
+ {
|
|
|
|
+ EventQueue.invokeLater(()->rebuildTable(false));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void triggerScheduleRefresh()
|
|
|
|
+ {
|
|
|
|
+ refreshScheduledItemList();
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|