Home | Trees | Indices | Help |
|
---|
|
1 # Copyright (C) 2012 Vaadin Ltd. 2 # Copyright (C) 2012 Richard Lincoln 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 16 from muntjac.ui.abstract_component import AbstractComponent 17 from muntjac.terminal.gwt.client.ui.v_media_base import VMediaBase 18 1921 """Abstract base class for the HTML5 media components. 22 23 @author: Vaadin Ltd 24 @author: Richard Lincoln 25 """ 2618828 self._sources = list() 29 self._showControls = None 30 self._altText = None 31 self._htmlContentAllowed = None 32 self._autoplay = None 33 self._muted = None 34 self._pause = None 35 self._play = None36 3739 """Sets a single media file as the source of the media component. 40 """ 41 del self._sources[:] 42 self.addSource(source)43 4446 """Adds an alternative media file to the sources list. Which of the 47 sources is used is selected by the browser depending on which file 48 formats it supports. See <a 49 href="http://en.wikipedia.org/wiki/HTML5_video#Table">wikipedia</a> 50 for a table of formats supported by different browsers. 51 """ 52 if source is not None: 53 self._sources.append(source) 54 self.requestRepaint()55 5658 """Set multiple sources at once. Which of the sources is used is 59 selected by the browser depending on which file formats it supports. 60 See <a 61 href="http://en.wikipedia.org/wiki/HTML5_video#Table">wikipedia</a> 62 for a table of formats supported by different browsers. 63 """ 64 self._sources.extend(sources) 65 self.requestRepaint()66 67 71 7274 """Sets whether or not the browser should show native media controls. 75 """ 76 self._showControls = showControls 77 self.requestRepaint()78 7981 """@return: true if the browser is to show native media controls.""" 82 return self._showControls83 8486 """Sets the alternative text to be displayed if the browser does not 87 support HTML5. This text is rendered as HTML if 88 L{setHtmlContentAllowed} is set to true. With HTML rendering, this 89 method can also be used to implement fallback to a flash-based player, 90 see the <a href= 91 "https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Using_Flash" 92 >Mozilla Developer Network</a> for details. 93 """ 94 self._altText = text 95 self.requestRepaint()96 9799 """@return: The text/html that is displayed when a browser doesn't 100 support HTML5. 101 """ 102 return self._altText103 104106 """Set whether the alternative text (L{setAltText}) is rendered as 107 HTML or not. 108 """ 109 self._htmlContentAllowed = htmlContentAllowed 110 self.requestRepaint()111 112114 """@return: true if the alternative text (L{setAltText}) is to be 115 rendered as HTML. 116 """ 117 return self._htmlContentAllowed118 119121 """Sets whether the media is to automatically start playback when 122 enough data has been loaded. 123 """ 124 self._autoplay = autoplay 125 self.requestRepaint()126 127129 """@return: true if the media is set to automatically start playback. 130 """ 131 return self._autoplay132 133135 """Set whether to mute the audio or not. 136 """ 137 self._muted = muted 138 self.requestRepaint()139 140 144 145147 """Pauses the media.""" 148 # cancel any possible play command 149 self._play = False 150 self._pause = True 151 self.requestRepaint()152 153155 """Starts playback of the media.""" 156 # cancel any possible pause command. 157 self._pause = False 158 self._play = True 159 self.requestRepaint()160 161163 super(AbstractMedia, self).paintContent(target) 164 target.addAttribute(VMediaBase.ATTR_CONTROLS, self.isShowControls()) 165 166 if self.getAltText() is not None: 167 target.addAttribute(VMediaBase.ATTR_ALT_TEXT, self.getAltText()) 168 169 target.addAttribute(VMediaBase.ATTR_HTML, self.isHtmlContentAllowed()) 170 171 target.addAttribute(VMediaBase.ATTR_AUTOPLAY, self.isAutoplay()) 172 173 for r in self.getSources(): 174 target.startTag(VMediaBase.TAG_SOURCE) 175 target.addAttribute(VMediaBase.ATTR_RESOURCE, r) 176 target.addAttribute(VMediaBase.ATTR_RESOURCE_TYPE, r.getMIMEType()) 177 target.endTag(VMediaBase.TAG_SOURCE) 178 179 target.addAttribute(VMediaBase.ATTR_MUTED, self.isMuted()) 180 181 if self._play: 182 target.addAttribute(VMediaBase.ATTR_PLAY, True) 183 self._play = False 184 185 if self._pause: 186 target.addAttribute(VMediaBase.ATTR_PAUSE, True) 187 self._pause = False
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Jun 5 20:45:20 2015 | http://epydoc.sourceforge.net |