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

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: 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
(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}
15 * @const
16 */
17 var CAST_COMMAND_LINE_FLAG = 'enable-video-player-chromecast-support';
18
19 chrome.commandLinePrivate.hasSwitch(CAST_COMMAND_LINE_FLAG, function(result) {
20 if (!result)
21 return;
22
23 CastExtensionDiscoverer.findInstalledExtension(onCastExtensionFound);
24 });
25
26 function onCastExtensionFound(extensionId) {
27 if (!extensionId) {
28 console.info('Cast extention is not found.');
29 return;
30 }
31
32 var api = document.createElement('script');
33 api.src = 'chrome-extension://' + extensionId + '/api_script.js';
34 api.onload = function() {
35 initializeCast(extensionId);
36 };
37 api.onerror = function() {
38 console.error('api_script.js load failed.');
39 };
40 document.body.appendChild(api);
41 };
42
43 function initializeCast(extensionId) {
44 loadCastExtensionApi();
45
46 castApi = new cast.ExtensionApi(extensionId);
47 castApi.addReceiverListener('ChromeCast', onReceiverUpdate);
48 }
49
50 function onReceiverUpdate(receivers) {
51 player.setCastList(receivers);
52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698