]>
git.proxmox.com Git - extjs.git/blob - extjs/modern/modern/src/Video.js
2 * Provides a simple Container for HTML5 Video.
6 * - There are quite a few issues with the `<video>` tag on Android devices. On Android 2+,
7 * the video will appear and play on first attempt, but any attempt afterwards will not work.
12 * - {@link #autoPause}
13 * - {@link #autoResume}
17 * - {@link #method-pause}
18 * - {@link #method-play}
23 * var panel = Ext.create('Ext.Panel', {
29 * url : 'porsche911.mov',
30 * posterUrl: 'porsche.png'
35 Ext
.define('Ext.Video', {
41 * @cfg {String/Array} url
42 * Location of the video to play. This should be in H.264 format and in a .mov file format.
47 * @cfg {String} posterUrl
48 * Location of a poster image to be shown before showing the video.
54 * @cfg {Boolean} [showPosterOnPause=true] When paused, the {@link #posterUrl}
55 * will be shown. If set to `false`, the poster will not be shown when the video
58 * Showing a poster may save on device resources as the `<video>` element is
59 * resource intensive whereas the `<img>` is not as intensive. Not showing a poster
60 * may slow down parts of the application including scrolling as the device is
61 * repainting the screen.
65 showPosterOnPause
: false
68 baseCls
: Ext
.baseCSSPrefix
+ 'video',
72 * @property {Ext.dom.Element} ghost
76 classList
: [Ext
.baseCSSPrefix
+ 'video-ghost']
80 classList
: [Ext
.baseCSSPrefix
+ 'media']
83 initialize: function() {
100 if (Ext
.os
.is
.Android4
|| Ext
.os
.is
.iPad
) {
101 this.isInlineVideo
= true;
105 applyUrl: function(url
) {
106 return [].concat(url
);
109 updateUrl: function(newUrl
) {
112 newLn
= newUrl
.length
,
113 existingSources
= media
.query('source'),
114 oldLn
= existingSources
.length
,
117 for (i
= 0; i
< oldLn
; i
++) {
118 Ext
.fly(existingSources
[i
]).destroy();
121 for (i
= 0; i
< newLn
; i
++) {
122 media
.appendChild(Ext
.Element
.create({
128 if (me
.isPlaying()) {
133 onActivate: function() {
137 onDeactivate: function() {
145 * Called when the {@link #ghost} element is tapped.
147 onGhostTap: function() {
159 * native video tag display only, move the media down so we can control the Viewport
161 onPause: function(e
) {
162 this.callParent([e
]);
164 // If the video is seeking, the browser may pause the video before setting
165 // the time to wherever the user clicked on.
166 if (!this.isInlineVideo
&& !e
.target
.seeking
&& this.getShowPosterOnPause()) {
174 * native video tag display only, move the media down so we can control the Viewport
176 onPlay: function(e
) {
177 this.callParent([e
]);
183 * Updates the URL to the poster, even if it is rendered.
184 * @param {Object} newUrl
186 updatePosterUrl: function(newUrl
) {
187 var ghost
= this.ghost
;
190 ghost
.setStyle('background-image', 'url(' + newUrl
+ ')');