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.JitcaException;
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 (JitcaException 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) {
}
@Override
public void onPlayerPlayEvent(IITTrack track) {
System.out.println((track.getName() + " by " + track.getArtist() + " started."));
}
@Override
public void onPlayerPlayingTrackChangedEvent(IITTrack arg0) {
}
@Override
public void onPlayerStopEvent(IITTrack track) {
System.out.println((track.getName() + " by " + track.getArtist() + " finished/stopped."));
}
@Override
public void onSoundVolumeChangedEvent(long arg0) {
}
@Override
public void onCOMCallsDisabledEvent(ITCOMDisabledReason arg0) {
}
@Override
public void onCOMCallsEnabledEvent() {
}
@Override
public void onAboutToPromptUserQuitEvent() {
}
@Override
public void onQuittingEvent() {
}
}