Source Code Cross Referenced for MP3Sound.java in  » Ajax » Laszlo-4.0.10 » org » openlaszlo » iv » flash » api » sound » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Ajax » Laszlo 4.0.10 » org.openlaszlo.iv.flash.api.sound 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: MP3Sound.java,v 1.2 2002/02/15 23:44:28 skavish Exp $
003:         *
004:         * ===========================================================================
005:         *
006:         */
007:
008:        package org.openlaszlo.iv.flash.api.sound;
009:
010:        import org.openlaszlo.iv.flash.parser.*;
011:        import org.openlaszlo.iv.flash.util.*;
012:        import org.openlaszlo.iv.flash.url.*;
013:        import org.openlaszlo.iv.flash.api.*;
014:
015:        import java.io.*;
016:
017:        /**
018:         * A sound whoose SOUNDDATA is in mp3 format
019:         *
020:         * @author James Taylor
021:         *
022:         */
023:
024:        public class MP3Sound extends Sound {
025:            public int delaySeek;
026:            public DataMarker data;
027:
028:            /** Create MP3Sound from url */
029:
030:            public static MP3Sound newMP3Sound(IVUrl url) throws IVException,
031:                    IOException {
032:                return newMP3Sound(Util.readUrl(url));
033:            }
034:
035:            /** Create MP3Sound from buffer */
036:
037:            public static MP3Sound newMP3Sound(FlashBuffer fob)
038:                    throws IVException, IOException {
039:                byte[] buffer;
040:
041:                // MP3Helper will load the MP3 from the url -- FIXME: need to consider the media cache here
042:
043:                MP3Helper mp3 = new MP3Helper(fob);
044:
045:                // Read the mp3 frames and put the into an array in memory. Must read
046:                // before extracting properties.
047:
048:                FlashBuffer fb = new FlashBuffer(fob.getSize());
049:
050:                while ((buffer = mp3.nextFrame()) != null) {
051:                    fb.writeArray(buffer, 0, buffer.length);
052:                }
053:
054:                MP3Sound sound = new MP3Sound();
055:
056:                sound.compressFormat = COMPRESS_MP3;
057:
058:                // Set the rate from the MP3's frequency
059:
060:                switch (mp3.getFrequency()) {
061:                case 11025:
062:                    sound.rate = RATE_11;
063:                    break;
064:                case 22050:
065:                    sound.rate = RATE_22;
066:                    break;
067:                case 44100:
068:                    sound.rate = RATE_44;
069:                    break;
070:                }
071:
072:                // MP3's are always 16 bit
073:
074:                sound.isSample16bit = true;
075:
076:                // Stereo includes anything that isn't mono ( joint stereo, dual mono )
077:
078:                sound.isStereo = mp3.getStereo();
079:
080:                // Sample count as determined for just the frames read
081:
082:                sound.sampleCount = mp3.getSamples();
083:
084:                // Default the delay seek to 0 until a better idea comes along
085:
086:                sound.delaySeek = 0;
087:
088:                // Datamarker containing just valid MP3 frames
089:                // no copying here!
090:                sound.data = new DataMarker(fb.getBuf(), 0, fb.getSize());
091:
092:                return sound;
093:            }
094:
095:            public int getSize() {
096:                return data.buffer.length;
097:            }
098:
099:            /** Write MP3Sound to output buffer */
100:
101:            public void write(FlashOutput fob) {
102:                fob.writeTag(getTag(), 2 + 1 + 4 + 2 + data.length());
103:                fob.writeDefID(this );
104:                fob.initBits();
105:                fob.writeBits(compressFormat, 4);
106:                fob.writeBits(rate, 2);
107:                fob.writeBool(isSample16bit);
108:                fob.writeBool(isStereo);
109:                fob.flushBits();
110:                fob.writeDWord(sampleCount);
111:                fob.writeWord(delaySeek); // Only addition for MP3SOUNDDATA
112:                data.write(fob);
113:            }
114:
115:            /** Copies this sound into the provided item ( must be an MP3Sound ) */
116:
117:            protected FlashItem copyInto(FlashItem item, ScriptCopier copier) {
118:                super .copyInto(item, copier);
119:
120:                ((MP3Sound) item).delaySeek = delaySeek;
121:                ((MP3Sound) item).data = (DataMarker) data.getCopy();
122:
123:                return item;
124:            }
125:
126:            /** Duplicates this sound */
127:
128:            public FlashItem getCopy(ScriptCopier copier) {
129:                return copyInto(new MP3Sound(), copier);
130:            }
131:
132:            /** DelaySeek accessor */
133:
134:            public int getDelaySeek() {
135:                return delaySeek;
136:            }
137:
138:            /** DelaySeek mutator */
139:
140:            public void setDelaySeek(int val) {
141:                delaySeek = val;
142:            }
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.