View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.util.launcher;
21  
22  import java.io.File;
23  import java.io.IOException;
24  
25  import org.xnap.XNap;
26  
27  /***
28   * Provides player support for Noatun through dcop.
29   */
30  public class NoatunPlayer extends DefaultPlayer
31  {
32      
33      //--- Constant(s) ---
34  
35      //--- Data field(s) ---
36  
37      //--- Constructor(s) ---
38  
39      public NoatunPlayer()
40      {
41  		super("noatun", XNap.tr("Noatun"), "");
42      }
43  
44      //--- Method(s) ---
45  
46      public boolean canPlay(File f)
47      {
48  		String lower = f.getName().toLowerCase();
49  		return super.canPlay(f) || lower.endsWith(".wav")
50  			|| lower.endsWith(".ogg") || lower.endsWith("mpg")
51  			|| lower.endsWith("mpeg");
52      }
53  
54      public boolean isEditable()
55      {
56  		return false;
57      }
58  
59      public void enqueue(File file) throws IOException
60      {
61  		String args[] = {
62  			"dcop", "noatun", "Noatun", "addFile", file.getAbsolutePath(), 
63  			"false"
64  		};
65  
66  		Runtime.getRuntime().exec(args);
67      }
68  
69      public void open(File file) throws IOException
70      {
71  		String args[] = {
72  			"dcop", "noatun", "Noatun", "addFile", file.getAbsolutePath(), 
73  			"true"
74  		};
75  
76  		Runtime.getRuntime().exec(args);
77      }
78  
79      public void start() throws IOException
80      {
81  		String args[] = {
82  			"dcop", "noatun", "Noatun", "playpause"
83  		};
84  	
85  		Runtime.getRuntime().exec(args);
86      }
87  
88      public void stop()
89      {
90  		String args[] = {
91  			"dcop", "noatun", "Noatun", "stop"
92  		};
93  
94  		try {
95  			Runtime.getRuntime().exec(args); 
96  		} 
97  		catch (IOException e) {
98  		}
99      }
100 
101 }