Results 1 to 16 of 16
Thread: Opening mp3 file ( not reading )
- 08-23-2010, 08:55 AM #1
Opening mp3 file ( not reading )
well i have a mp3 file on my desktop and after i run my program, i want it to open it..
basically like opening it with double clicking on it, but ill just give my program a path.
actually the mp3 is a radiochannel streaming link or smthing like thatJava Code:C:\Users\Desktop\powerhit.mp3
this is what happens when i open it normally.
-
Your question may be missing some information. For one, I'm not sure how it relates to Java programming.
Luck.
- 08-23-2010, 01:47 PM #3
well my whole idea is that ... my java code (program) is running and if certain something occurs, then i want java to open the mp3 file
hows this not java programming ? hmmz :(
- 08-23-2010, 02:16 PM #4
It might help if you post the java code you are currently using to try and open the MP3 streaming link. Then maybe someone could show you where you are going wrong?
-
Sorry, I got it. So how in your Java program do you try to call the program that plays the mp3 code? Are you using Runtime.exec(...)? If so, are you running into problems? Again, more details may help.
edit: and if you are using Runtime.exec(...) have you read this article? http://www.javaworld.com/javaworld/j...229-traps.html
Luck.
- 08-24-2010, 10:07 AM #6
this is what im doing..
ˇJava Code:import java.awt.*; import java.awt.event.*; public class Counter { public static void main(String[] args) throws Exception { Robot robot = new Robot(); robot.delay(3000); Runtime load = Runtime.getRuntime(); load.exec("C:/Users/Jansu/Desktop/powerhit.mp3"); } }
Java Code:Exception in thread "main" java.io.IOException: Cannot run program "C:/Users/Jansu/Desktop/powerhit.mp3": CreateProcess error=193, %1 is not a valid Win32 application at java.lang.ProcessBuilder.start(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at java.lang.Runtime.exec(Unknown Source) at Counter.main(Counter.java:12) Caused by: java.io.IOException: CreateProcess error=193, %1 is not a valid Win32 application at java.lang.ProcessImpl.create(Native Method) at java.lang.ProcessImpl.<init>(Unknown Source) at java.lang.ProcessImpl.start(Unknown Source) ... 5 more
- 08-27-2010, 03:38 AM #7
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4
load.exec("C:/Users/Jansu/Desktop/powerhit.mp3");
the arguments inside of .exec is not a valid file path.
- 08-27-2010, 07:12 PM #8
no it seems to me that the path is valid, but with load.exec i can open only exe files not mp3 files ?
- 08-27-2010, 07:36 PM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
- 08-28-2010, 02:28 PM #10
Provided the computer has a default application associated with mp3 files, you can run it via Desktop#open(...)
db
- 08-28-2010, 03:01 PM #11
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
Hi,
Darryl's solution is probably the simplest to your requirement. And you need Java 1.6 to use the java.awt.Desktop class.Website: Learn Java by Examples
- 08-28-2010, 03:18 PM #12
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,413
- Blog Entries
- 7
- Rep Power
- 17
- 08-28-2010, 03:31 PM #13
Senior Member
- Join Date
- Jun 2007
- Location
- Bali, Indonesia
- Posts
- 696
- Rep Power
- 6
I think for the default file type association should be better handled by the operating system :) Or, if you still want to do it you can execute the "assoc" or "ftype" command if you are using MS Windows.
Last edited by wsaryada; 08-28-2010 at 03:35 PM.
Website: Learn Java by Examples
- 08-28-2010, 08:04 PM #14
im sure its possible to change association with java too hehe
but thanks darryl...you solved it
SOLVEDJava Code:import java.awt.*; import java.io.*; public class Test { public static void main (String[] args) throws Exception { Desktop d = Desktop.getDesktop(); File f = new File("C:/Users/Jansu/Desktop/powerhit.mp3"); d.open(f); } }Last edited by Char; 08-28-2010 at 08:08 PM.
- 08-28-2010, 11:48 PM #15
- 08-29-2010, 07:09 AM #16
got it working like this also
weirdest thing is that when i change the \\ infront of users to / it gives me an errorJava Code:import java.awt.*; import java.io.*; public class Test { public static void main (String[] args) throws Exception { Runtime load = Runtime.getRuntime(); load.exec(" \"C:/Program Files (x86)/VideoLAN/VLC/vlc.exe\" \"C:\\Users/Jansu/Desktop/powerhit.mp3\" "); } }
Similar Threads
-
Opening .html file
By Prajin in forum New To JavaReplies: 7Last Post: 08-06-2010, 07:20 AM -
Error While Opening A PDF file
By Cluster Storm in forum AWT / SwingReplies: 6Last Post: 06-07-2010, 06:03 PM -
Opening applet with .html file
By Atriamax in forum New To JavaReplies: 12Last Post: 09-13-2009, 06:26 AM -
Opening a custom proyect file
By janpol1 in forum EclipseReplies: 0Last Post: 02-04-2009, 02:29 PM -
Problem in opening a file
By Raghav kv in forum New To JavaReplies: 1Last Post: 08-11-2007, 01:55 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks