VideoPanel.js
1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Ext JS Library 0.30
* Copyright(c) 2006-2009, Ext JS, LLC.
* licensing@extjs.com
*
* http://extjs.com/license
*/
/**
* @class Ext.air.VideoPanel
* @extends Ext.Panel
*/
Ext.air.VideoPanel = Ext.extend(Ext.Panel, {
// Properties
autoResize: true,
// Overriden methods
initComponent: function() {
var connection = new air.NetConnection();
connection.connect(null);
this.stream = new runtime.flash.net.NetStream(connection);
this.stream.client = {
onMetaData: Ext.emptyFn
};
Ext.air.VideoPanel.superclass.initComponent.call(this);
this.on('bodyresize', this.onVideoResize, this);
},
afterRender: function() {
Ext.air.VideoPanel.superclass.afterRender.call(this);
(function() {
var box = this.body.getBox();
this.video = new air.Video(this.getInnerWidth(), this.getInnerHeight());
if (this.url) {
this.video.attachNetStream(this.stream);
this.stream.play(this.url);
}
nativeWindow.stage.addChild(this.video);
this.video.x = box.x;
this.video.y = box.y;
}).defer(500, this);
},
// Custom Methods
onVideoResize: function(pnl, w, h) {
if (this.video && this.autoResize) {
var iw = this.getInnerWidth();
var ih = this.getInnerHeight();
this.video.width = iw
this.video.height = ih;
var xy = this.body.getXY();
if (xy[0] !== this.video.x) {
this.video.x = xy[0];
}
if (xy[1] !== this.video.y) {
this.video.y = xy[1];
}
}
},
loadVideo: function(url) {
this.stream.close();
this.video.attachNetStream(this.stream);
this.stream.play(url);
}
});
Ext.reg('videopanel', Ext.air.VideoPanel);