Solved

invoke winamp from java program

Posted on 2001-07-24
10
300 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

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…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

758 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

21 Experts available now in Live!

Get 1:1 Help Now