/*
* 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 OpenAndPlayPlaylistAction extends Action {
private String _playlistName;
public OpenAndPlayPlaylistAction(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);
new OpenPlaylistAction(playlistItem.getName()).run();
Controller.getInstance().getPlaylistController().playFile(playlistItem, firstAudioItem);
} catch (Exception e) {
Log.getInstance(OpenAndPlayPlaylistAction.class).error("Error while opening and playing playlist: " + e.getMessage()); //$NON-NLS-1$
}
}
}
}