Solved

invoke winamp from java program

Posted on 2001-07-24
10
303 Views
Last Modified: 2009-12-16
Hi,
   Can anyone show me how to invoke winamp program to play the speify song form a java program? Where should I start?
0
Comment
Question by:mkngau
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 9

Accepted Solution

by:
Ovi earned 50 total points
ID: 6316018
public class AppRunner {
     public static void main(String[] args) {
          String app = "c:\\Progra~1\\Winamp\\Winamp.exe";
    try {
         Process process = Runtime.getRuntime().exec(app);
    } catch(Exception e) {}
     }
}
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6316023
Or, if your PATH system variable points to the winamp directory, you can modify the string app into simply "winamp.exe". Here is an example of starting Winamp with the G:\\ as start pats ("my cdRom drive")

public class AppRunner {
     public static void main(String[] args) {
          String app = "c:\\Progra~1\\Winamp\\winamp.exe g:\\";
    try {
         Process process = Runtime.getRuntime().exec(app);
    } catch(Exception e) {}
     }
}
0
 
LVL 92

Expert Comment

by:objects
ID: 6316032
I think in fact if your Windoze installation is already setup so to open your sound files with winamp (ie. the file type is associated with winamp).
Then you don't even need to specify winamp explicitly, the OS will fire it up automagically.
Save you hardcoding the Winamp location, and also means if you change your player in the future you don't need to modify your application.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 92

Expert Comment

by:objects
ID: 6316035
Try:

String file = "song.mp3";
Process process = Runtime.getRuntime().exec("start "+file);
0
 
LVL 6

Expert Comment

by:kotan
ID: 6316047
There are a few of command line option for Winamp:

Try,

C:\path\to\winamp\winamp.exe /ADD C:\mp3\whatever.mp3
(Adds C:\mp3\whatever.mp3 to the playlist of a running Winamp, if Winamp is running, otherwise it opens Winamp and plays it outright)

C:\path\to\winamp\winamp.exe /NEW
(Creates a new instance of Winamp, even if Winamp is already running)

C:\path\to\winamp\winamp.exe C:\mp3\file.mp3
(Plays the file C:\mp3\file.mp3, regardless of whether or not Winamp is open)

C:\path\to\winamp\winamp.exe /CLASS="myclassname"
(Opens Winamp with a different Window Class name "myclassname")
0
 

Author Comment

by:mkngau
ID: 6316637
Thanks for your help.
But how if I want to remote the winamp to play a song in another pc?
0
 
LVL 92

Expert Comment

by:objects
ID: 6316721
Well why didn't you ask that in the first place?
So do you want winamp to start up on another pc?
Or do you want to play a song located on another pc?

0
 

Author Comment

by:mkngau
ID: 6320481
Sorry...the requirement has changed so I need to modify my code.
  What I need to do is, run the program in machine A to invoke song in Machine B(winamp and mp3 files is on Machine B) thru internet or LAN. Is it possible.
0
 
LVL 6

Expert Comment

by:kotan
ID: 6320495
You can use RMI method to do that.
0
 

Author Comment

by:mkngau
ID: 6320609
Can u show me how to do that? Now I manage to invoke the winamp in server using servlet...but how if I want to remote another client machine?
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now