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