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

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

Issue 381073003: Video Player: Add a cast menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 'use strict';
6
7 /**
8 * The instance of cast api.
9 * @type {cast.ExtensionApi}
10 */
11 var castApi = null;
12
13 /**
14 * @type {string}
fukino 2014/07/11 04:35:50 nit: @const
15 */
16 var CAST_COMMAND_LINE_FLAG = 'enable-video-player-chromecast-support';
17
18 chrome.commandLinePrivate.hasSwitch(CAST_COMMAND_LINE_FLAG, function(result) {
19 if (!result)
20 return;
21
22 CastExtensionDiscoverer.findInstalledExtension(onCastExtensionFound);
23 });
24
25 function onCastExtensionFound(extensionId) {
26 if (!extensionId) {
27 console.info('Cast extention is not found.');
28 return;
29 }
30
31 var api = document.createElement('script');
32 api.src = 'chrome-extension://' + extensionId + '/api_script.js';
33 api.onload = function() {
34 initializeCast(extensionId);
35 };
36 api.onerror = function() {
37 console.error('api_script.js load failed.');
38 };
39 document.body.appendChild(api);
40 };
41
42 function initializeCast(extensionId) {
43 loadCastExtensionApi();
44
45 castApi = new cast.ExtensionApi(extensionId);
46 castApi.addReceiverListener('ChromeCast', onReceiverUpdate);
47 }
48
49 function onReceiverUpdate(receivers) {
50 player.setCastList(receivers);
51 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698