1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from muntjac.ui.abstract_media import AbstractMedia
17 from muntjac.terminal.gwt.client.ui.v_video import VVideo
18
19
20 -class Video(AbstractMedia):
21 """The Video component translates into an HTML5 C{<video>} element and as
22 such is only supported in browsers that support HTML5 media markup.
23 Browsers that do not support HTML5 display the text or HTML set by calling
24 L{setAltText}.
25
26 A flash-player fallback can be implemented by setting HTML content allowed
27 (L{setHtmlContentAllowed} and calling L{setAltText} with the flash player
28 markup. An example of flash fallback can be found at the <a href=
29 "https://developer.mozilla.org/En/Using_audio_and_video_in_Firefox#Using_Flash"
30 >Mozilla Developer Network</a>.
31
32 Multiple sources can be specified. Which of the sources is used is selected
33 by the browser depending on which file formats it supports. See <a
34 href="http://en.wikipedia.org/wiki/HTML5_video#Table">wikipedia</a> for a
35 table of formats supported by different browsers.
36
37 @author: Vaadin Ltd
38 @author: Richard Lincoln
39 """
40
41 CLIENT_WIDGET = None
42
43 - def __init__(self, caption='', source=None):
44 """@param caption:
45 The caption for this video.
46 @param source:
47 The resource containing the video to play.
48 """
49 self._poster = None
50
51 self.setCaption(caption)
52 self.setSource(source)
53 self.setShowControls(True)
54
55
56 - def setPoster(self, poster):
57 """Sets the poster image, which is shown in place of the video before
58 the user presses play.
59 """
60 self._poster = poster
61
62
63 - def getPoster(self):
64 """@return The poster image."""
65 return self._poster
66
67
68 - def paintContent(self, target):
69 super(Video, self).paintContent(target)
70 if self.getPoster() is not None:
71 target.addAttribute(VVideo.ATTR_POSTER, self.getPoster())
72