Package org.jampa.gui.actions.playlist

Source Code of org.jampa.gui.actions.playlist.PlayPlaylistAction

/*
* Jampa
* Copyright (C) 2008-2009 J. Devauchelle and contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 3 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*/

package org.jampa.gui.actions.playlist;

import org.eclipse.jface.action.Action;
import org.jampa.controllers.Controller;
import org.jampa.logging.Log;
import org.jampa.model.IAudioItem;
import org.jampa.model.playlists.Playlist;

public class PlayPlaylistAction extends Action {
 
  private String _playlistName;
 
  public PlayPlaylistAction(String playlistName) {
    _playlistName = playlistName;   
  }
 
  public void run() {
    if ((_playlistName != null) &&
        (!_playlistName.isEmpty())) {
     
      try {
        Playlist playlistItem = Controller.getInstance().getPlaylistController().getPlaylistByName(_playlistName);
        IAudioItem firstAudioItem = playlistItem.getAudioItemByIndex(0);
        Controller.getInstance().getPlaylistController().playFile(playlistItem, firstAudioItem);
      } catch (Exception e) {
        Log.getInstance(PlayPlaylistAction.class).error("Error while playing playlist: " + e.getMessage());   //$NON-NLS-1$
      }
    }
  }
}
TOP

Related Classes of org.jampa.gui.actions.playlist.PlayPlaylistAction

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.