Jump to content
Sign in to follow this  
neddie

Launching Totem from java

Recommended Posts

I posted this already in another forum but I've got no responses so maybe the Mandriva guys can help me here...

 

I've got a java program, and one of the things it should be able to do is play sound files. Now, I can play some wavs directly from java, but not all wavs (UnsupportedAudioFileException) and not oggs or mp3s. I can add a bunch of libraries to let me play oggs, but I can't guarantee that people have those libraries and don't want to include them all myself. So I figure why not just launch the system's media player and pass the file over?

 

So I tried using "Desktop.getDesktop().open(soundFile)" and it certainly launches Totem, but Totem just says "Location not found" and the java program spits out the following error to the console:

** Message: Error: Resource not found.
gstfilesrc.c(977): gst_file_src_start (): /play/source:
No such file "/home/neddie/code/test/file:/home/neddie/sounds/test.wav"

 

I can print out the file's path, and check that it exists and is readable, but somehow it seems to be passing a file:/ url (to the absolute file path) which is then getting misinterpreted as a relative url (appended to the current path) and obviously then it doesn't work. Note that I can double-click on the file in Nautilus and Totem plays the file no problem.

 

Does anyone know, is this a Totem problem, or just a misconfig of my system, or what? If I do the same thing with a text file then it opens gedit ok, if I use a jpeg it opens the picture player ok, and if I change the default wav-file handler to either mplayer or VLC then they also work. So it must be specific to Totem I guess.

 

Or does anyone know if there's a more reliable method for launching a sound player in a cross-platform way?

 

And while I'm here, does anyone know an easy way to determine the duration of a sound clip, whether it's wav or ogg or mp3 or whatever? Preferably without my program having to understand all the audio formats and preferably without having to read the whole file into memory? I see that Nautilus is able to show the length of audio files on the "audio" tab, but is there any way for a java program to access that meta-information?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...