fang2.media
Class RawMediaCache

java.lang.Object
  extended by java.lang.Thread
      extended by fang2.media.RawMediaCache
All Implemented Interfaces:
Runnable

public class RawMediaCache
extends Thread

This class facilitates loading and caching content from a URL off the main execution thread. Since the FANG Engine advanceFrame must happen quickly (about 1/25th of a second), media must be either loaded off the main execution thread or delay the game. This class loads and stores the exact contents of the URL which is usually in compressed format, and has options for loading off and on the main execution thread.

Author:
jam

Nested Class Summary
static interface RawMediaCache.MediaLoadListener
           
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Method Summary
static InputStream getCachedStream(URL url)
           
static boolean hasLoadError(URL url)
           
static boolean isCurrentlyLoading(URL url)
           
static boolean isFullyLoaded(URL url)
           
static void load(URL url)
           
static void load(URL url, RawMediaCache.MediaLoadListener listener)
           
static byte[] loadAndWait(URL url)
           
static void main(String[] args)
           
 void run()
          If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

load

public static void load(URL url)

loadAndWait

public static byte[] loadAndWait(URL url)

load

public static void load(URL url,
                        RawMediaCache.MediaLoadListener listener)

isCurrentlyLoading

public static boolean isCurrentlyLoading(URL url)

isFullyLoaded

public static boolean isFullyLoaded(URL url)

hasLoadError

public static boolean hasLoadError(URL url)

getCachedStream

public static InputStream getCachedStream(URL url)

run

public void run()
Description copied from class: Thread
If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns.

Subclasses of Thread should override this method.

Specified by:
run in interface Runnable
Overrides:
run in class Thread
See Also:
Thread.start(), Thread.stop(), Thread.Thread(java.lang.ThreadGroup, java.lang.Runnable, java.lang.String), Runnable.run()

main

public static void main(String[] args)
Parameters:
args -