public void frameUpdate(float timePerFrame) { // TODO Auto-generated method stub // TODO Play Frame, when in the right time => Sync-Playback-rate /* * // Put A Frame according to its Framerate * TODO: Declare private long controller; private long frameWait; private long starttime; private int iteration; Initialize starttime = System.currentTimeMillis(); controller = System.currentTimeMillis(); frameWait = 1000 / perf.getFramerate(); iteration = 0; This one into the update function: if (System.currentTimeMillis() >= (controller + frameWait)){ controller = System.currentTimeMillis(); System.out.println("There you go: " + System.currentTimeMillis()); drawFrame(); iteration++; } if (System.currentTimeMillis() > (starttime + (iteration*frameWait)+frameWait)) { // skip Frame iteration += 2; System.out.println("Look ma, no hands: " + iteration); } */ // timer.getTimePerFrame(); if (oggDecoder.isReady()) { oggDecoder.readBody(); TextureManager.releaseTexture(texture.getTextureKey()); texture = TextureManager.loadTexture( Toolkit.getDefaultToolkit().createImage(oggDecoder.getYUVBuffer()), MinificationFilter.BilinearNearestMipMap, MagnificationFilter.Bilinear, true); if (texture != null) { if (textureState != null) textureState = DisplaySystem.getDisplaySystem().getRenderer().createTextureState(); textureState.setTexture(texture); quad.setRenderState(textureState); quad.updateRenderState(); } } }
/** * Get the Sound based on a specified OGG file * * @param ref The reference to the OGG file in the classpath * @param in The stream to the OGG to load * @return The Sound read from the OGG file * @throws IOException Indicates a failure to load the OGG */ public Audio getOgg(String ref, InputStream in) throws IOException { if (!soundWorks) { return new NullAudio(); } if (!inited) { throw new RuntimeException( "Can't load sounds until SoundStore is init(). Use the container init() method."); } if (deferred) { return new DeferredSound(ref, in, DeferredSound.OGG); } int buffer = -1; if (loaded.get(ref) != null) { buffer = ((Integer) loaded.get(ref)).intValue(); } else { try { IntBuffer buf = BufferUtils.createIntBuffer(1); OggDecoder decoder = new OggDecoder(); OggData ogg = decoder.getData(in); AL10.alGenBuffers(buf); AL10.alBufferData( buf.get(0), ogg.channels > 1 ? AL10.AL_FORMAT_STEREO16 : AL10.AL_FORMAT_MONO16, ogg.data, ogg.rate); loaded.put(ref, new Integer(buf.get(0))); buffer = buf.get(0); } catch (Exception e) { Log.error(e); Log.info("Failed to load: " + ref + " - " + e.getMessage()); throw new IOException("Unable to load: " + ref); } } if (buffer == -1) { throw new IOException("Unable to load: " + ref); } return new AudioImpl(this, buffer); }
public VideoTexture(String name, String file) { super(name); // getInputStreamFromFile(file); this.file = file; getInputStream(file); if (inputStream == null) { System.err.println("InputStream is empty!"); } else { createShape(); oggDecoder = new OggDecoder(inputStream); oggDecoder.start(); } }