diff options
Diffstat (limited to 'node_modules/montage-user/ui/video-player.reel/video-player.js')
-rwxr-xr-x | node_modules/montage-user/ui/video-player.reel/video-player.js | 368 |
1 files changed, 368 insertions, 0 deletions
diff --git a/node_modules/montage-user/ui/video-player.reel/video-player.js b/node_modules/montage-user/ui/video-player.reel/video-player.js new file mode 100755 index 00000000..e2832ce0 --- /dev/null +++ b/node_modules/montage-user/ui/video-player.reel/video-player.js | |||
@@ -0,0 +1,368 @@ | |||
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 | "use strict"; | ||
7 | /** | ||
8 | @module montage/ui/video-player | ||
9 | @requires montage | ||
10 | @requires montage/ui/component | ||
11 | @requires core/logger | ||
12 | @requires core/event/action-event-listener | ||
13 | @requires ui/controller/media-controller | ||
14 | */ | ||
15 | var Montage = require("montage").Montage, | ||
16 | Component = require("ui/component").Component, | ||
17 | logger = require("core/logger").logger("video-player"), | ||
18 | ActionEventListener = require("core/event/action-event-listener").ActionEventListener, | ||
19 | MediaController = require("ui/controller/media-controller").MediaController; | ||
20 | /** | ||
21 | @class module:montage/ui/video-player.VideoPlayer | ||
22 | */ | ||
23 | var VideoPlayer = exports.VideoPlayer = Montage.create(Component,/** @lends module:montage/ui/video-player.VideoPlayer# */ { | ||
24 | |||
25 | /*----------------------------------------------------------------------------- | ||
26 | MARK: Constants | ||
27 | -----------------------------------------------------------------------------*/ | ||
28 | /** | ||
29 | The interval in milliseconds that the control panel is displayed without interaction before being hidden. | ||
30 | @type {number} | ||
31 | @default 5000 | ||
32 | */ | ||
33 | CONTROL_SHOW_TIME: { enumerable: true, value: 5000, writable: false }, | ||
34 | /*----------------------------------------------------------------------------- | ||
35 | MARK: Element Getters | ||
36 | -----------------------------------------------------------------------------*/ | ||
37 | /** | ||
38 | The DIV element used to display the play button in the media controller. | ||
39 | @type {external:Element} | ||
40 | @default null | ||
41 | */ | ||
42 | playButton: { value: null, enumerable: false }, | ||
43 | |||
44 | /** | ||
45 | The DIV element used to display the repeat button in the media controller. | ||
46 | @type {external:Element} | ||
47 | @default null | ||
48 | */ | ||
49 | repeatButton: { value: null, enumerable: false }, | ||
50 | |||
51 | /** | ||
52 | The DIV element used to display the volume level in the media controller. | ||
53 | @type {external:Element} | ||
54 | @default null | ||
55 | */ | ||
56 | volumeLevel: { value: null, enumerable: false }, | ||
57 | |||
58 | /** | ||
59 | The DIV element used to display the volume level in the media controller. | ||
60 | @type {external:Element} | ||
61 | @default null | ||
62 | */ | ||
63 | controls: { value: null, enumerable: false }, | ||
64 | |||
65 | /** | ||
66 | The DIV element used to display the in the media controller. | ||
67 | @type {external:Element} | ||
68 | @default null | ||
69 | */ | ||
70 | fullScreenPanel: { value: null, enumerable: false }, | ||
71 | /** | ||
72 | Description TODO | ||
73 | @type {external:Element} | ||
74 | @default null | ||
75 | */ | ||
76 | fullScreenButton: { value: null, enumerable: false }, | ||
77 | |||
78 | /*----------------------------------------------------------------------------- | ||
79 | MARK: Component References | ||
80 | -----------------------------------------------------------------------------*/ | ||
81 | /** | ||
82 | The DynamicText component used to display the currently playing track's playback position. | ||
83 | @type {module:montage/ui/dynamic-text.DynamicText} | ||
84 | @default null | ||
85 | */ | ||
86 | positionText: { value: null, enumerable: false }, /* montage/ui/dynamic-text */ | ||
87 | |||
88 | /** | ||
89 | The DynamicText component used to display the currently playing track's duration. | ||
90 | @type {module:montage/ui/dynamic-text.DynamicText} | ||
91 | @default null | ||
92 | */ | ||
93 | durationText: { value: null, enumerable: false }, /* montage/ui/dynamic-text */ | ||
94 | |||
95 | /** | ||
96 | The Slider component used to control the playback position. | ||
97 | @type {module:montage/ui/slider.Slider} | ||
98 | @default null | ||
99 | */ | ||
100 | slider: { value: null, enumerable: false }, /* montage/ui/slider */ | ||
101 | /*----------------------------------------------------------------------------- | ||
102 | MARK: Properties | ||
103 | -----------------------------------------------------------------------------*/ | ||
104 | /** | ||
105 | The MediaController instance used by the VideoPlayer. | ||
106 | @type {module:montage/ui/controller/media-controller.MediaController} | ||
107 | @default null | ||
108 | */ | ||
109 | controller: { value: null, enumerable: false }, /* montage/controller/media-controller */ | ||
110 | |||
111 | /** | ||
112 | The source URL for the video. | ||
113 | @type {string} | ||
114 | @default null | ||
115 | */ | ||
116 | src: { value: null }, | ||
117 | /*----------------------------------------------------------------------------- | ||
118 | MARK: Actions | ||
119 | -----------------------------------------------------------------------------*/ | ||
120 | /*----------------------------------------------------------------------------- | ||
121 | MARK: UI Setters | ||
122 | -----------------------------------------------------------------------------*/ | ||
123 | /** | ||
124 | Determines whether video controls are hidden automatically. | ||
125 | @type {Boolean} | ||
126 | @default true | ||
127 | */ | ||
128 | autoHide: { value: true }, | ||
129 | |||
130 | /** | ||
131 | Specifies whether the full screen video is supported. | ||
132 | @type {Boolean} | ||
133 | @default true | ||
134 | */ | ||
135 | supportsFullScreen: { value: true }, | ||
136 | |||
137 | /** | ||
138 | @private | ||
139 | */ | ||
140 | _isFullScreen: { value: false }, | ||
141 | |||
142 | templateDidLoad: { | ||
143 | value: function() { | ||
144 | if(logger.isDebug) { | ||
145 | logger.debug("MediaController:templateDidLoad"); | ||
146 | } | ||
147 | Object.defineBinding(this.positionText, "value", { | ||
148 | boundObject: this.controller, | ||
149 | boundObjectPropertyPath: "position", | ||
150 | boundValueMutator: this._prettyTime | ||
151 | }); | ||
152 | Object.defineBinding(this.durationText, "value", { | ||
153 | boundObject: this.controller, | ||
154 | boundObjectPropertyPath: "duration", | ||
155 | boundValueMutator: this._prettyTime | ||
156 | }); | ||
157 | Object.defineBinding(this.slider, "maxValue", { | ||
158 | boundObject: this.controller, | ||
159 | boundObjectPropertyPath: "duration", | ||
160 | boundValueMutator: this._roundTime, | ||
161 | oneWay: false | ||
162 | }); | ||
163 | } | ||
164 | }, | ||
165 | /** | ||
166 | @private | ||
167 | */ | ||
168 | _prettyTime: { | ||
169 | value: function(time) { | ||
170 | var sec, min, hour; | ||
171 | time = parseInt(time, 10); | ||
172 | if (isNaN(time) || time < 0) | ||
173 | return ""; | ||
174 | sec = time % 60; | ||
175 | min = Math.floor(time / 60) % 60; | ||
176 | hour = Math.floor(time / 3600); | ||
177 | return (hour > 0 ? hour + ":" : "") + (min < 10 ? "0"+min : min) + ":" + (sec < 10 ? "0"+sec : sec); | ||
178 | } | ||
179 | }, | ||
180 | /** | ||
181 | @private | ||
182 | */ | ||
183 | _roundTime: { | ||
184 | value: function(time) { | ||
185 | return (time < 0 ? 0 : Math.floor(time)); | ||
186 | } | ||
187 | }, | ||
188 | /** | ||
189 | Description TODO | ||
190 | @function | ||
191 | @private | ||
192 | */ | ||
193 | handleMediaStateChange: { | ||
194 | value: function() { | ||
195 | this.needsDraw = true; | ||
196 | } | ||
197 | }, | ||
198 | /*----------------------------------------------------------------------------- | ||
199 | MARK: Interaction | ||
200 | -----------------------------------------------------------------------------*/ | ||
201 | /** | ||
202 | Description TODO | ||
203 | @private | ||
204 | */ | ||
205 | _showControls: { | ||
206 | value: true, enumerable: false | ||
207 | }, | ||
208 | /** | ||
209 | Description TODO | ||
210 | @private | ||
211 | */ | ||
212 | _hideControlsId: { | ||