package basic;
import java.util.Scanner;
import com.jitcaforwin.basic.iTunesApp;
import com.jitcaforwin.basic.api.IITObject;
import com.jitcaforwin.basic.api.IITTrack;
import com.jitcaforwin.basic.api.IiTunes;
import com.jitcaforwin.basic.api.IiTunesEventsListener;
import com.jitcaforwin.basic.enums.ITCOMDisabledReason;
import com.jitcaforwin.main.exceptions.JitcaGeneralException;
public class EventDemo {
public static void main(String args[]) {
try {
IiTunes iTunes = new iTunesApp();
IiTunesEventsListener demoListener = new DemoEventHandler();
iTunes.addEventListener(demoListener);
System.out.println("Enter for exit!");
Scanner in = new Scanner(System.in);
in.nextLine();
iTunes.close();
} catch (JitcaGeneralException e) {
e.printStackTrace();
}
}
}
class DemoEventHandler implements IiTunesEventsListener {
/*
* Note: It is not necessary to implement all methods of the interface. The
* interface IiTunesEventsListener is divided into several subinterfaces
* which are responsible for one specific task.
*/
@Override
public void handleException(Exception e) {
e.printStackTrace();
}
@Override
public void onDatabaseChangedEvent(IITObject[] arg0, IITObject[] arg1) {
// TODO Auto-generated method stub
}
@Override
public void onPlayerPlayEvent(IITTrack track) {
try {
System.out
.println((track.getName() + " by " + track.getArtist() + " started."));
} catch (JitcaGeneralException e) {
e.printStackTrace();
}
}
@Override
public void onPlayerPlayingTrackChangedEvent(IITTrack arg0) {
// TODO Auto-generated method stub
}
@Override
public void onPlayerStopEvent(IITTrack track) {
try {
System.out
.println((track.getName() + " by " + track.getArtist() + " finished/stopped."));
} catch (JitcaGeneralException e) {
e.printStackTrace();
}
}
@Override
public void onSoundVolumeChangedEvent(long arg0) {
// TODO Auto-generated method stub
}
@Override
public void onCOMCallsDisabledEvent(ITCOMDisabledReason arg0) {
// TODO Auto-generated method stub
}
@Override
public void onCOMCallsEnabledEvent() {
// TODO Auto-generated method stub
}
@Override
public void onAboutToPromptUserQuitEvent() {
// TODO Auto-generated method stub
}
@Override
public void onQuittingEvent() {
// TODO Auto-generated method stub
}
}