This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Apple + sound + permission

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm having problems playing sound in my first applet please help.

This is the code i use:


And i get this error:
Access denied (Java.lang.RuntimePermission getProtectionDomain)

I have tried and google it and i seems like it is a permission rights on file problem.
How do i fix that i cant find an example.

Thanks in advanced,
Carsten S. Rasmussen

It might be a newbie question but its relevant, at least for me :O)

 
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For starters, this is a bad idea: catch (Exception e) { }. At least log an error message so that you know that a problem occurred.

Secondly, applets have no access to the local file system. Assuming that you intend the audio file to be loaded from the server (where the applet resides), the URL must be an "http://..." URL.

If the file really is on the local file system (which would be very strange for an applet, which are not generally allowed to access to it for good reasons), see HowCanAnAppletReadFilesOnTheLocalFileSystem.
 
Carsten Rasmussen
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my url is http://localhost/sounds/send.wav how do i add that i tried just now and applet wont run:


I checked that the file is there and its working but still i cant play it.
 
Carsten Rasmussen
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you could explain me howto make a java policy file that would be a good help.
thanks.
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's odd, the code should work. In an applet you should use getAudioClip(...), not Applet.newAudioClip(...), by the way.

In the Java Console, can you see the audio file being successfully downloaded, with no error messages?

Maybe you could explain me howto make a java policy file


No policy file (or signed applet) is needed since the file now comes from the same server that hosts the applet.
 
Carsten Rasmussen
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EHmm, how do i get the console in ubuntu linux ???
thanks by the way
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like this: http://www.java.com/en/download/help/5000021200.xml
 
Carsten Rasmussen
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If i install self extracting java i will overide package default-java isn't there another way to tell if sound is downloaded maybe an applet code.
 
Carsten Rasmussen
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im using this code:

What is wrong what is it I'm doing wrong/missing ???
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't understand what you're saying about "self extracting Java". There's probably an exception in the Console.

Alternatively, you can check the web server access logs to see if the file is accessed and served properly.
 
Carsten Rasmussen
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"self extracting java" is a way to add java in Ubuntu. I have no console.
I have no logs, isn't there a solution within the code ?
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could open a popup window that displays the stack trace.
 
Carsten Rasmussen
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know howto do that, but i did this code:

And the sound played perfectly. So how do i play sound in web applet ???
 
Ulf Dittmer
Rancher
Posts: 43027
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code you had before is fine, there's no need to change it. As I said, there's probably an exception, so you need to find a way to log or display it. I recommend you search for how to enable the Java Console on your system.
 
What do you have in that there bucket? It wouldn't be a tiny ad by any chance ...
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic