diff options
author | Valerio Virgillito | 2012-02-01 00:09:27 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-01 00:09:27 -0800 |
commit | 8592cfb89db05f0e52d8c1b8c7046e6f49e3522d (patch) | |
tree | a6f9b5adfe16fd6232708f8a2345cd79056caca9 /node_modules/montage-user/ui/controller/media-controller.js | |
parent | c6d1a1da9e7cdf477daf32410d80691eb1e828d5 (diff) | |
download | ninja-8592cfb89db05f0e52d8c1b8c7046e6f49e3522d.tar.gz |
Adding a montage framework copy for the user document
Adding a new montage copy containing the latest version of montage to use the new native widgets
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage-user/ui/controller/media-controller.js')
-rwxr-xr-x | node_modules/montage-user/ui/controller/media-controller.js | 698 |
1 files changed, 698 insertions, 0 deletions
diff --git a/node_modules/montage-user/ui/controller/media-controller.js b/node_modules/montage-user/ui/controller/media-controller.js new file mode 100755 index 00000000..0663a526 --- /dev/null +++ b/node_modules/montage-user/ui/controller/media-controller.js | |||
@@ -0,0 +1,698 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | /** | ||
7 | @module montage/ui/controller/media-controller | ||
8 | @requires montage/core/core | ||
9 | @requires montage/ui/component | ||
10 | @requires core/logger | ||
11 | */ | ||
12 | var Montage = require("montage").Montage; | ||
13 | var Component = require("ui/component").Component; | ||
14 | var logger = require("core/logger").logger("mediacontroller"); | ||
15 | /** | ||
16 | @class module:montage/ui/controller/media-controller.MediaController | ||
17 | @classdesc Controls an audio/video media player. | ||
18 | @extends module:montage/core/core.Montage | ||
19 | |||
20 | */ | ||
21 | var MediaController = exports.MediaController = Montage.create(Montage, /** @lends module:montage/ui/controller/media-controller.MediaController# */ { | ||
22 | /*----------------------------------------------------------------------------- | ||
23 | MARK: Constants | ||
24 | -----------------------------------------------------------------------------*/ | ||
25 | /** | ||
26 | Description TODO | ||
27 | @type {Property} | ||
28 | @default {Number} 0 | ||
29 | */ | ||
30 | STOPPED: { enumerable: true, value: 0, writable: false }, | ||
31 | /** | ||
32 | Description TODO | ||
33 | @type {Property} | ||
34 | @default {Number} 1 | ||
35 | */ | ||
36 | PLAYING: { enumerable: true, value: 1, writable: false }, | ||
37 | /** | ||
38 | Description TODO | ||
39 | @type {Property} | ||
40 | @default {Number} 2 | ||
41 | */ | ||
42 | PAUSED: { enumerable: true, value: 2, writable: false }, | ||
43 | /** | ||
44 | Description TODO | ||
45 | @type {Property} | ||
46 | @default {Number} 3 | ||
47 | */ | ||
48 | EMPTY: { enumerable: true, value: 3, writable: false }, | ||
49 | /** | ||
50 | Description TODO | ||
51 | @private | ||
52 | */ | ||
53 | _TIMEUPDATE_FREQUENCY: { value: 0.25 }, // Don't refresh too often. | ||
54 | /*----------------------------------------------------------------------------- | ||
55 | MARK: Properties | ||
56 | -----------------------------------------------------------------------------*/ | ||
57 | /** | ||
58 | Description TODO | ||
59 | @private | ||
60 | */ | ||
61 | _mediaElement: { | ||
62 | value: null, | ||
63 | enumerable: false | ||
64 | }, | ||
65 | /** | ||
66 | Description TODO | ||
67 | @type {Function} | ||
68 | @default null | ||
69 | */ | ||
70 | mediaElement: { | ||
71 | get : function() { | ||
72 | return this._mediaElement; | ||
73 | }, | ||
74 | set : function(elem) { | ||
75 | this._mediaElement = elem; | ||
76 | }, | ||
77 | enumerable: false | ||
78 | }, | ||
79 | /** | ||
80 | Description TODO | ||
81 | @private | ||
82 | */ | ||
83 | _mediaSrc: { | ||
84 | value: null, | ||
85 | enumerable: false | ||
86 | }, | ||
87 | /** | ||
88 | Description TODO | ||
89 | @type {Function} | ||
90 | @default null | ||
91 | */ | ||
92 | mediaSrc: { | ||
93 | get: function() { | ||
94 | return this._mediaSrc; | ||
95 | }, | ||
96 | set: function(mediaSrc) { | ||
97 | this._mediaSrc = mediaSrc; | ||
98 | } | ||
99 | }, | ||
100 | /*----------------------------------------------------------------------------- | ||
101 | MARK: Status & Attributes | ||
102 | -----------------------------------------------------------------------------*/ | ||
103 | /** | ||
104 | Description TODO | ||
105 | @private | ||
106 | */ | ||
107 | _status: { | ||
108 | enumerable: false, | ||
109 | value: 3 | ||
110 | }, | ||
111 | /** | ||
112 | Description TODO | ||
113 | @type {Function} | ||
114 | @default {Number} 3 | ||
115 | */ | ||
116 | status: { | ||
117 | enumerable: false, | ||
118 | get: function() { | ||
119 | return this._status; | ||
120 | }, | ||
121 | set: function(status) { | ||
122 | if (status !== this._status) { | ||
123 | this._status = status; | ||
124 | this._dispatchStateChangeEvent(); | ||
125 | } | ||
126 | } | ||
127 | }, | ||
128 | /** | ||
129 | Description TODO | ||
130 | @private | ||
131 | */ | ||
132 | _position: { value:null, enumerable:false }, | ||
133 | |||
134 | /** | ||
135 | Description TODO | ||
136 | @type {Function} | ||
137 | @default null | ||
138 | */ | ||
139 | position: { | ||
140 | set: function(time, shouldNotUpdate) { | ||
141 | this._position = time; | ||
142 | if (!shouldNotUpdate) { | ||
143 | this.currentTime = time; | ||
144 | } | ||
145 | }, | ||
146 | get: function() { | ||
147 | return this._position; | ||
148 | } | ||
149 | }, | ||
150 | /** | ||
151 | Description TODO | ||
152 | @private | ||
153 | */ | ||
154 | _duration: { value: null, enumerable:false }, | ||
155 | /** | ||
156 | Description TODO | ||
157 | @type {Function} | ||
158 | @default null | ||
159 | */ | ||
160 | duration: { | ||
161 | set: function(time) { | ||
162 | if (isNaN(time)) { | ||
163 | if (logger.isDebug) { | ||
164 | logger.debug("MediaController:setDuration: duration is not valid"); | ||
165 | } | ||
166 | return; | ||
167 | } | ||
168 | if (logger.isDebug) { | ||
169 | logger.debug("MediaController:setDuration: duration=" + time); | ||
170 | } | ||
171 | this._duration = time; | ||
172 | }, | ||
173 | get: function() { | ||
174 | return this._duration; | ||
175 | } | ||
176 | }, | ||
177 | /*----------------------------------------------------------------------------- | ||
178 | MARK: Media Player Commands | ||
179 | -----------------------------------------------------------------------------*/ | ||
180 | /** | ||
181 | Description TODO | ||
182 | @type {Property} | ||
183 | @default {Boolean} true | ||
184 | */ | ||
185 | autoplay: { | ||
186 | enumerable: false, | ||
187 | value: true | ||
188 | }, | ||
189 | /** | ||
190 | Description TODO | ||
191 | @function | ||
192 | */ | ||
193 | play: { | ||
194 | value: function() { | ||
195 | if (logger.isDebug) { | ||
196 | logger.debug("MediaController:play()"); | ||
197 | } | ||
198 | this.mediaElement.play(); | ||
199 | } | ||
200 | }, | ||
201 | /** | ||
202 | Description TODO | ||
203 | @function | ||
204 | */ | ||
205 | pause: { | ||
206 | value: function() { | ||
207 | if (logger.isDebug) { | ||
208 | logger.debug("MediaController:pause()"); | ||
209 | } | ||
210 | this.mediaElement.pause(); | ||
211 | } | ||
212 | }, | ||
213 |