1 50 51 package org.openlaszlo.iv.flash.api.sound; 52 53 import org.openlaszlo.iv.flash.parser.*; 54 import org.openlaszlo.iv.flash.util.*; 55 import java.io.PrintStream ; 56 import org.openlaszlo.iv.flash.api.*; 57 58 public class LazySound extends Sound { 59 60 protected DataMarker data; 61 62 public LazySound() {} 63 64 public static LazySound parse( Parser p ) { 65 LazySound sound = new LazySound(); 66 sound.setID( p.getUWord() ); 67 p.initBits(); sound.compressFormat = p.getBits(4); 69 sound.rate = p.getBits(2); 70 sound.isSample16bit = p.getBool(); 71 sound.isStereo = p.getBool(); 72 sound.sampleCount = p.getUDWord(); 73 sound.data = new DataMarker( p.getBuf(), p.getPos(), p.getTagEndPos() ); 75 return sound; 76 } 77 78 public void write( FlashOutput fob ) { 79 fob.writeTag( getTag(), 2+1+4+data.length() ); 80 fob.writeDefID( this ); 81 fob.initBits(); 82 fob.writeBits( compressFormat, 4 ); 83 fob.writeBits( rate, 2 ); 84 fob.writeBool( isSample16bit ); 85 fob.writeBool( isStereo ); 86 fob.flushBits(); 87 fob.writeDWord( sampleCount ); 88 data.write(fob); 89 } 90 91 public int getSize() { 92 return data.buffer.length; 93 } 94 95 protected FlashItem copyInto( FlashItem item, ScriptCopier copier ) { 96 97 super.copyInto( item, copier ); 98 99 ((LazySound)item).data = (DataMarker) data.getCopy(); 100 101 return item; 102 } 103 104 public FlashItem getCopy( ScriptCopier copier ) { 105 return copyInto( new LazySound(), copier ); 106 } 107 } 108 | Popular Tags |