Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

invoke winamp from java program

Posted on 2001-07-24
10
305 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
more than one jdk and one jre 1 50
Error in @AspectJ Based AOP with Spring 2 18
hibernate example using maven 12 58
ejb wildfly example 2 25
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

828 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