Solved

invoke winamp from java program

Posted on 2001-07-24
10
302 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

863 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

24 Experts available now in Live!

Get 1:1 Help Now