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/SoundLoader.java,v 1.4 2004/05/10 14:58:54 tj_willis Exp $
019     */ 
020    package net.sourceforge.pavlov.randommedia;
021    
022    import java.applet.*;
023    import java.net.URL;
024    import org.apache.log4j.*;
025    
026    /**
027     * Describe class <code>SoundLoader</code> here.
028     *
029     * @author <a href="mailto:tj_willis@users.sourceforge.net">T.J. Willis</a>
030     * @version 1.0
031     */
032    public class SoundLoader extends Thread {
033        private SoundList soundList;
034        private URL url;
035        private Category cat
036            = Category.getInstance(SoundLoader.class.getName());
037        /**
038         * Creates a new <code>SoundLoader</code> instance.
039         *
040         * @param soundList a <code>SoundList</code> value
041         * @param myURL an <code>URL</code> value
042         * @param priority an <code>int</code> value
043         */
044        public SoundLoader(SoundList soundList,URL myURL, int priority) 
045        {
046            this.soundList = soundList;
047            url = myURL;
048            setPriority(priority);
049            //setPriority(MIN_PRIORITY);
050            cat.debug("Loader loading " + url);
051            start();
052        }
053    
054        /**
055         * Describe <code>run</code> method here.
056         *
057         */
058        public void run() {
059            cat.debug("Loader running for: " + url);
060            AudioClip audioClip = Applet.newAudioClip(url);
061            soundList.add(audioClip);
062            cat.debug("Loaded clip " + url);
063        }
064    }