/*
* 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.podcast;
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.podcasts.Podcast;
public class OpenAndPlayPodcastAction extends Action {
private String _podcastName;
public OpenAndPlayPodcastAction(String podcastName) {
_podcastName = podcastName;
}
public void run() {
if ((_podcastName != null) &&
(!_podcastName.isEmpty())) {
try {
Podcast podcastItem = Controller.getInstance().getPlaylistController().getPodcastByName(_podcastName);
IAudioItem firstAudioItem = podcastItem.getAudioItemByIndex(0);
new OpenPodcastAction(podcastItem.getName()).run();
Controller.getInstance().getPlaylistController().playFile(podcastItem, firstAudioItem);
} catch (Exception e) {
Log.getInstance(OpenAndPlayPodcastAction.class).error("Error while opening and playing podcast: " + e.getMessage()); //$NON-NLS-1$
}
}
}
}