StartStopListener is related to the events of the media server starting (nowPlaying method) and ending (donePlaying) serving a media file.
Following quick example shows how the nowPlaying method is used to show a fairly annoying MessageBox.
- Code: Select all
package net.pms.external;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import net.pms.dlna.DLNAMediaInfo;
import net.pms.dlna.DLNAResource;
public class AudioListenerSkel implements StartStopListener{
@Override
public void donePlaying(DLNAMediaInfo media, DLNAResource resource) {
// TODO Auto-generated method stub
}
@Override
public void nowPlaying(DLNAMediaInfo media, DLNAResource resource) {
// Annoy all the people with a MessageBox when a file is being served
JOptionPane.showMessageDialog(null,
media.getFirstAudioTrack().songname,
"Now Playing",
JOptionPane.INFORMATION_MESSAGE);
}
@Override
public JComponent config() {
//Returns a JComponent that is usually a JPanel
//Is called via a button in the General Configuration tab
return null;
}
@Override
public String name() {
// Returns the label on the button that is being used for configuration
return "Now Playing example";
}
@Override
public void shutdown() {
// In case you need to close some network link or file handler
}
}
