Package basic

Source Code of basic.DemoEventHandler

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.basic.exceptions.ObjectDeletedException;
import com.jitcaforwin.basic.exceptions.TrackDeletedException;

public class EventDemo {
  public static void main(String args[]) {
    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();

  }

}

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 onDatabaseChangedEvent(IITObject[] arg0, IITObject[] arg1) {
  }

  @Override
  public void onPlayerPlayEvent(IITTrack track) {
    try {
      System.out.println((track.getName() + " by " + track.getArtist() + " started."));
    } catch (TrackDeletedException e) {
      e.printStackTrace();
    } catch (ObjectDeletedException e) {
      e.printStackTrace();
    }
  }

  @Override
  public void onPlayerPlayingTrackChangedEvent(IITTrack arg0) {

  }

  @Override
  public void onPlayerStopEvent(IITTrack track) {
    try {
      System.out.println((track.getName() + " by " + track.getArtist() + " finished/stopped."));
    } catch (TrackDeletedException e) {
      e.printStackTrace();
    } catch (ObjectDeletedException e) {
      e.printStackTrace();
    }

  }

  @Override
  public void onSoundVolumeChangedEvent(long arg0) {

  }

  @Override
  public void onCOMCallsDisabledEvent(ITCOMDisabledReason arg0) {

  }

  @Override
  public void onCOMCallsEnabledEvent() {

  }

  @Override
  public void onAboutToPromptUserQuitEvent() {

  }

  @Override
  public void onQuittingEvent() {

  }

}
TOP

Related Classes of basic.DemoEventHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.