Package basic

Source Code of basic.CreatingPlaylistDemo

package basic;

import com.jitcaforwin.basic.iTunesApp;
import com.jitcaforwin.basic.api.IITTrack;
import com.jitcaforwin.basic.api.IITTrackCollection;
import com.jitcaforwin.basic.api.IITUserPlaylist;
import com.jitcaforwin.basic.api.IiTunes;
import com.jitcaforwin.main.exceptions.JitcaException;


public class CreatingPlaylistDemo {

  public static void main(String args[]) {
    try {
      IiTunes iTunes = new iTunesApp();

      IITTrackCollection selectedTracks = iTunes.getSelectedTracks();

      if (selectedTracks == null) {
        System.out.println("No tracks selected!");
      } else {
        IITUserPlaylist newPlaylist = iTunes.createPlaylist(
            "SelectedTracks").getUserPlaylist();

        boolean hasNext = true;
        int i = 1;

        while (hasNext) {
          IITTrack track = selectedTracks.item(i);
          if (track == null) {
            hasNext = false;
          } else {
            System.out.println(track.getName() + " by "
                + track.getArtist() + " added to playlist.");
            newPlaylist.addTrack(track);
            i++;
          }
        }

        double sizeMB = newPlaylist.getSize() / 1000000;
        String duration = newPlaylist.getTime();
        String name = newPlaylist.getName();

        System.out.println("Playlist \"" + name
            + "\" created. \nSize of the playlist: " + sizeMB
            + "MB. \nDuration of playlist: " + duration);
      }

      iTunes.close();

    } catch (JitcaException e) {
      e.printStackTrace();
    }

  }
}
TOP

Related Classes of basic.CreatingPlaylistDemo

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.