Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: ui/file_manager/video_player/js/video_player.js

Issue 381073003: Video Player: Add a cast menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comment Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 /** 7 /**
8 * @param {Element} playerContainer Main container. 8 * @param {Element} playerContainer Main container.
9 * @param {Element} videoContainer Container for the video element. 9 * @param {Element} videoContainer Container for the video element.
10 * @param {Element} controlsContainer Container for video controls. 10 * @param {Element} controlsContainer Container for video controls.
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 var closeButton = document.querySelector('.close-button'); 159 var closeButton = document.querySelector('.close-button');
160 closeButton.addEventListener( 160 closeButton.addEventListener(
161 'click', 161 'click',
162 function(event) { 162 function(event) {
163 close(); 163 close();
164 event.stopPropagation(); 164 event.stopPropagation();
165 }.wrap(null)); 165 }.wrap(null));
166 closeButton.addEventListener('mousedown', preventDefault); 166 closeButton.addEventListener('mousedown', preventDefault);
167 167
168 var castButton = document.querySelector('.cast-button');
169 cr.ui.decorate(castButton, cr.ui.MenuButton);
170 castButton.addEventListener(
171 'click',
172 function(event) {
173 event.stopPropagation();
174 }.wrap(null));
175 castButton.addEventListener('mousedown', preventDefault);
176
177 var menu = document.querySelector('#cast-menu');
178 cr.ui.decorate(menu, cr.ui.Menu);
179
168 this.controls_ = new FullWindowVideoControls( 180 this.controls_ = new FullWindowVideoControls(
169 document.querySelector('#video-player'), 181 document.querySelector('#video-player'),
170 document.querySelector('#video-container'), 182 document.querySelector('#video-container'),
171 document.querySelector('#controls')); 183 document.querySelector('#controls'));
172 184
173 var reloadVideo = function(e) { 185 var reloadVideo = function(e) {
174 if (this.controls_.decodeErrorOccured && 186 if (this.controls_.decodeErrorOccured &&
175 // Ignore shortcut keys 187 // Ignore shortcut keys
176 !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) { 188 !e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey) {
177 this.reloadCurrentVideo_(function() { 189 this.reloadCurrentVideo_(function() {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 * 351 *
340 * @param {function()=} opt_callback Completion callback. 352 * @param {function()=} opt_callback Completion callback.
341 * @private 353 * @private
342 */ 354 */
343 VideoPlayer.prototype.reloadCurrentVideo_ = function(opt_callback) { 355 VideoPlayer.prototype.reloadCurrentVideo_ = function(opt_callback) {
344 var currentVideo = this.videos_[this.currentPos_]; 356 var currentVideo = this.videos_[this.currentPos_];
345 this.loadVideo_(currentVideo.fileUrl, currentVideo.entry.name, opt_callback); 357 this.loadVideo_(currentVideo.fileUrl, currentVideo.entry.name, opt_callback);
346 }; 358 };
347 359
348 /** 360 /**
361 * Set the list of casts.
362 * @param {Array.<Object>} casts List of casts.
363 */
364 VideoPlayer.prototype.setCastList = function(casts) {
365 var button = document.querySelector('.cast-button');
366 var menu = document.querySelector('#cast-menu');
367 menu.innerHTML = '';
368
369 if (casts.length === 0) {
370 button.classList.add('hidden');
371 return;
372 }
373
374 for (var i = 0; i < casts.length; i++) {
375 var item = new cr.ui.MenuItem();
376 item.textContent = casts[i].name;
377 menu.appendChild(item);
378 }
379 button.classList.remove('hidden');
380 };
381
382 /**
349 * Initialize the list of videos. 383 * Initialize the list of videos.
350 * @param {function(Array.<Object>)} callback Called with the video list when 384 * @param {function(Array.<Object>)} callback Called with the video list when
351 * it is ready. 385 * it is ready.
352 */ 386 */
353 function initVideos(callback) { 387 function initVideos(callback) {
354 if (window.videos) { 388 if (window.videos) {
355 var videos = window.videos; 389 var videos = window.videos;
356 window.videos = null; 390 window.videos = null;
357 callback(videos); 391 callback(videos);
358 return; 392 return;
(...skipping 23 matching lines...) Expand all
382 var initPromise = Promise.all( 416 var initPromise = Promise.all(
383 [new Promise(initVideos.wrap(null)), 417 [new Promise(initVideos.wrap(null)),
384 new Promise(initStrings.wrap(null)), 418 new Promise(initStrings.wrap(null)),
385 new Promise(util.addPageLoadHandler.wrap(null))]); 419 new Promise(util.addPageLoadHandler.wrap(null))]);
386 420
387 initPromise.then(function(results) { 421 initPromise.then(function(results) {
388 var videos = results[0]; 422 var videos = results[0];
389 player.prepare(videos); 423 player.prepare(videos);
390 return new Promise(player.playFirstVideo.wrap(player)); 424 return new Promise(player.playFirstVideo.wrap(player));
391 }.wrap(null)); 425 }.wrap(null));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698