3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
17 * Copyright(c) 2006-2011 Sencha Inc.
18 * licensing@sencha.com
19 * http://www.sencha.com/license
22 // From code originally written by David Davis (http://www.sencha.com/blog/html5-video-canvas-and-ext-js/)
24 Ext.define('MyDesktop.VideoWindow', {
25 extend: 'Ext.ux.desktop.Module',
28 'Ext.ux.desktop.Video'
32 windowId: 'video-window',
41 handler : this.createWindow,
46 createWindow : function(){
47 var me = this, desktop = me.app.getDesktop(),
48 win = desktop.getWindow(me.windowId);
51 win = desktop.createWindow({
53 title: 'About Ext JS',
66 // browser will pick the format it likes most:
67 { src: 'http://dev.sencha.com/desktopvideo.mp4', type: 'video/mp4' },
68 { src: 'http://dev.sencha.com/desktopvideo.ogv', type: 'video/ogg' },
69 { src: 'http://dev.sencha.com/desktopvideo.mov', type: 'video/quicktime' }
76 afterrender: function(video) {
77 me.videoEl = video.video.dom;
79 if (video.supported) {
80 me.tip = new Ext.tip.ToolTip({
83 height : me.tipHeight,
86 '<canvas width="', me.tipWidth,
87 '" height="', me.tipHeight, '">'
93 afterrender: me.onTooltipRender,
94 show: me.renderPreview,
104 beforedestroy: function() {
105 me.tip = me.ctx = me.videoEl = null;
114 me.tip.setTarget(win.taskButton.el);
120 onTooltipRender: function (tip) {
121 // get the canvas 2d context
122 var el = tip.body.dom, me = this;
123 me.ctx = el.getContext && el.getContext('2d');
126 renderPreview: function() {
129 if ((me.tip && !me.tip.isVisible()) || !me.videoEl) {
135 me.ctx.drawImage(me.videoEl, 0, 0, me.tipWidth, me.tipHeight);
139 // 20ms to keep the tooltip video smooth
140 Ext.Function.defer(me.renderPreview, 20, me);