001 /* PAVLOV -- Multiple Choice Study System
002 * Copyright (C) 2000 - 2004 T.J. Willis
003 *
004 * This program is free software; you can redistribute it and/or
005 * modify it under the terms of the GNU General Public License
006 * as published by the Free Software Foundation; either version 2
007 * of the License, or (at your option) any later version.
008 *
009 * This program is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012 * GNU General Public License for more details.
013 *
014 * You should have received a copy of the GNU General Public License
015 * along with this program; if not, write to the Free Software
016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
017 *
018 * $Header: /cvsroot/pavlov/net/sourceforge/pavlov/randommedia/SoundList.java,v 1.3 2004/05/10 14:58:54 tj_willis Exp $
019 */
020 package net.sourceforge.pavlov.randommedia;
021
022
023 import java.applet.AudioClip;
024 import org.apache.log4j.*;
025
026 /**
027 * Loads and holds a bunch of audio files whose locations are specified
028 * relative to a fixed base URL.
029 * @author <a href="mailto:tj_willis@users.sourceforge.net">T.J. Willis</a>
030 * @version 1.0
031 */
032 public class SoundList extends MediaCache {
033
034 /**
035 * Creates a new <code>SoundList</code> instance.
036 *
037 * @param p a <code>RandomURLProvider</code> value
038 * @param size an <code>int</code> value
039 */
040 public SoundList(RandomURLProvider p, int size) {
041 super(p,size);
042 }
043
044 /**
045 * Describe <code>getClip</code> method here.
046 *
047 * @return an <code>AudioClip</code> value
048 */
049 public AudioClip getClip() {
050 AudioClip clip = (AudioClip) getObject();
051 manageCache();
052 return clip;
053 // return (AudioClip) getObject();
054 }
055
056 /**
057 * Describe <code>playClip</code> method here.
058 *
059 */
060 public void playClip()
061 {
062 AudioClip clip = getClip();
063 if(clip==null){
064 //System.out.println("No clips available!");
065 //FIXME: change this to synchronously load/play a clip
066 return;
067 }
068 // clip.play();
069 new SoundPlayer(clip);
070 manageCache();
071 }
072
073 /**
074 * Describe <code>getContentLoader</code> method here.
075 *
076 * @return a <code>ContentLoader</code> value
077 */
078 public ContentLoader getContentLoader()
079 {
080 return new SoundContentLoader();
081 }
082 }