Source Code Cross Referenced for Audio.java in  » Ajax » zk » org » zkoss » zul » 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 » zk » org.zkoss.zul 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Audio.java
002:
003:        {{IS_NOTE
004:        	Purpose:
005:        		
006:        	Description:
007:        		
008:        	History:
009:        		Wed Nov 16 11:48:27     2005, Created by tomyeh
010:        }}IS_NOTE
011:
012:        Copyright (C) 2005 Potix Corporation. All Rights Reserved.
013:
014:        {{IS_RIGHT
015:        	This program is distributed under GPL Version 2.0 in the hope that
016:        	it will be useful, but WITHOUT ANY WARRANTY.
017:        }}IS_RIGHT
018:         */
019:        package org.zkoss.zul;
020:
021:        import org.zkoss.lang.Objects;
022:        import org.zkoss.util.media.Media;
023:        import org.zkoss.xml.HTMLs;
024:
025:        import org.zkoss.zk.ui.Desktop;
026:        import org.zkoss.zk.ui.Execution;
027:        import org.zkoss.zk.ui.UiException;
028:        import org.zkoss.zk.ui.WrongValueException;
029:        import org.zkoss.zk.ui.ext.render.DynamicMedia;
030:        import org.zkoss.zk.au.out.AuInvoke;
031:
032:        import org.zkoss.zul.impl.XulElement;
033:        import org.zkoss.zul.impl.Utils;
034:
035:        /**
036:         * An audio clip.
037:         *
038:         * <p>An extension to XUL.
039:         *
040:         * @author tomyeh
041:         */
042:        public class Audio extends XulElement {
043:            private String _align, _border;
044:            protected String _src;
045:            /** The audio. If not null, _src is generated automatically. */
046:            private org.zkoss.sound.Audio _audio;
047:            /** Count the version of {@link #_audio}. */
048:            private int _audver;
049:            private boolean _autostart, _loop;
050:
051:            public Audio() {
052:            }
053:
054:            public Audio(String src) {
055:                setSrc(src);
056:            }
057:
058:            /** Plays the audio at the client.
059:             */
060:            public void play() {
061:                response("ctrl", new AuInvoke(this , "play"));
062:            }
063:
064:            /** Stops the audio at the cient.
065:             */
066:            public void stop() {
067:                response("ctrl", new AuInvoke(this , "stop"));
068:            }
069:
070:            /** Pauses the audio at the cient.
071:             */
072:            public void pause() {
073:                response("ctrl", new AuInvoke(this , "pause"));
074:            }
075:
076:            /** Returns the alignment.
077:             * <p>Default: null (use browser default).
078:             */
079:            public String getAlign() {
080:                return _align;
081:            }
082:
083:            /** Sets the alignment: one of top, texttop, middle, absmiddle,
084:             * bottom, absbottom, baseline, left, right and center.
085:             */
086:            public void setAlign(String align) throws WrongValueException {
087:                if (align != null && align.length() == 0)
088:                    align = null;
089:
090:                if (!Objects.equals(_align, align)) {
091:                    _align = align;
092:                    smartUpdate("align", _align);
093:                }
094:            }
095:
096:            /** Returns the width of the border.
097:             * <p>Default: null (use browser default).
098:             */
099:            public String getBorder() {
100:                return _border;
101:            }
102:
103:            /** Sets the width of the border.
104:             */
105:            public void setBorder(String border) throws WrongValueException {
106:                if (border != null && border.length() == 0)
107:                    border = null;
108:
109:                if (!Objects.equals(_border, border)) {
110:                    _border = border;
111:                    smartUpdate("border", _border);
112:                }
113:            }
114:
115:            /** Returns the src.
116:             * <p>Default: null.
117:             */
118:            public String getSrc() {
119:                return _src;
120:            }
121:
122:            /** Sets the src.
123:             *
124:             * <p>If {@link #setContent} is ever called with non-null,
125:             * it takes heigher priority than this method.
126:             */
127:            public void setSrc(String src) {
128:                if (src != null && src.length() == 0)
129:                    src = null;
130:
131:                if (!Objects.equals(_src, src)) {
132:                    _src = src;
133:                    if (_audio == null)
134:                        updateSrc();
135:                    //_src is meaningful only if _audio is null
136:                }
137:            }
138:
139:            private String getEncodedSrc() {
140:                final Desktop dt = getDesktop();
141:                return _audio != null ? getAudioSrc() : //already encoded
142:                        dt != null ? dt.getExecution().encodeURL(
143:                                _src != null ? _src : "~./aud/mute.mid") : "";
144:            }
145:
146:            /** Returns whether to auto start playing the audio.
147:             *
148:             * <p>Default: false;
149:             */
150:            public final boolean isAutostart() {
151:                return _autostart;
152:            }
153:
154:            /** Sets whether to auto start playing the audio.
155:             */
156:            public final void setAutostart(boolean autostart) {
157:                if (_autostart != autostart) {
158:                    _autostart = autostart;
159:                    smartUpdate("autostart", _autostart);
160:                }
161:            }
162:
163:            /** Sets the content directly.
164:             * Default: null.
165:             *
166:             * @param audio the audio to display. If not null, it has higher
167:             * priority than {@link #getSrc}.
168:             */
169:            public void setContent(org.zkoss.sound.Audio audio) {
170:                if (audio != _audio) {
171:                    _audio = audio;
172:                    if (_audio != null)
173:                        ++_audver; //enforce browser to reload
174:                    updateSrc();
175:                }
176:            }
177:
178:            private void updateSrc() {
179:                invalidate();
180:                //IE won't work if we only change the src attribute
181:            }
182:
183:            /** Returns the content set by {@link #setContent}.
184:             * <p>Note: it won't fetch what is set thru by {@link #setSrc}.
185:             * It simply returns what is passed to {@link #setContent}.
186:             */
187:            public org.zkoss.sound.Audio getContent() {
188:                return _audio;
189:            }
190:
191:            /** Returns the encoded URL for the current audio content.
192:             * Don't call this method unless _audio is not null;
193:             */
194:            private String getAudioSrc() {
195:                return Utils.getDynamicMediaURI(this , _audver,
196:                        _audio.getName(), _audio.getFormat());
197:            }
198:
199:            //-- super --//
200:            public String getOuterAttrs() {
201:                final StringBuffer sb = new StringBuffer(64).append(super 
202:                        .getOuterAttrs());
203:                HTMLs.appendAttribute(sb, "src", getEncodedSrc());
204:                HTMLs.appendAttribute(sb, "autostart", _autostart);
205:                HTMLs.appendAttribute(sb, "loop", _loop);
206:                HTMLs.appendAttribute(sb, "align", _align);
207:                HTMLs.appendAttribute(sb, "border", _border);
208:                return sb.toString();
209:            }
210:
211:            //-- Component --//
212:            /** Default: not childable.
213:             */
214:            public boolean isChildable() {
215:                return false;
216:            }
217:
218:            //-- ComponentCtrl --//
219:            protected Object newExtraCtrl() {
220:                return new ExtraCtrl();
221:            }
222:
223:            /** A utility class to implement {@link #getExtraCtrl}.
224:             * It is used only by component developers.
225:             */
226:            protected class ExtraCtrl extends XulElement.ExtraCtrl implements 
227:                    DynamicMedia {
228:                //-- DynamicMedia --//
229:                public Media getMedia(String pathInfo) {
230:                    return _audio;
231:                }
232:            }
233:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.