Sign My Guestbook
View My Guestbook
This Malaysian Underground+Alternative WebRing is owned by MEOR ' THE PIRATE '-. Want to join the Malaysian Underground+Alternative WebRing? |
---|
[Skip Prev] [Prev] [Next] [Skip Next] [Random] [Next 5] [List Sites] |
* Note that the URL is constructed relative to the * getDocumentBase(), that is because the url is obtained * from within the document */ public void next() { try { if (audio != null) { audio.stop(); audio = null; } String url = sounds; if (sounds.indexOf('|') >= 0) { int start = index; if ((index = sounds.indexOf('|', index)) < 0) { url = sounds.substring(start); index = start; } else { url = sounds.substring(start, index++); } } if (url.length() > 0) { audio = getAudioClip(new URL(getDocumentBase(), url)); audio.play(); } } catch(Exception e) { } } /** * Initialize the applet. First resize it, then get the * "snd" attribute. */ public void init() { resize(10, 12); sounds = getParameter("snd"); if (sounds == null) { sounds = "doc:/demo/audio/ding.au"; } } /** * When the applet is started play the next sound. */ public void start() { next(); } /** * When the applet is stopped, stop playing the current sound. */ public void stop() { if (audio != null) { audio.stop(); audio = null; } } /** * When the user clicks in the applet, play the next sound. */ public boolean mouseUp(java.awt.Event evt, int x, int y) { next(); return true; } /** * Paint an audio icon. */ public void paint(Graphics g) { double f = ((double)(size().height - 1)) / ((size().width - 1) * 2); int offset = size().height / 2; for (int i = size().width - 1; i >= 0; i -= 3) { int h = (int)(i * f); g.drawLine(i, offset - h, i, offset + h); } } public String getAppletInfo() { return "Title: AudioItem\nAuthor: James Gosling\nA simple Item class to play an audio clip."; } public String[][] getParameterInfo() { String pinfo[][] = { {"snd", "string", "The sound URL(s).You can specify a list of them by seperating the sounds by '|'s. Note that the URL is constructed relative to the getDocumentBase() because the url is obtained from within the document."} }; return pinfo; } }