Package org.jampa.gui.actions.podcast

Source Code of org.jampa.gui.actions.podcast.OpenAndPlayPodcastAction

/*
* 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$
      }
    }
  }

}
TOP

Related Classes of org.jampa.gui.actions.podcast.OpenAndPlayPodcastAction

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.