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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/video_player/js/cast/caster.js
diff --git a/ui/file_manager/video_player/js/cast/caster.js b/ui/file_manager/video_player/js/cast/caster.js
new file mode 100644
index 0000000000000000000000000000000000000000..6ff0831c63a3b11b60dddca5fa81ccc6cd21002a
--- /dev/null
+++ b/ui/file_manager/video_player/js/cast/caster.js
@@ -0,0 +1,52 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+'use strict';
+
+/**
+ * The instance of cast api.
+ * @type {cast.ExtensionApi}
+ */
+var castApi = null;
+
+/**
+ * @type {string}
+ * @const
+ */
+var CAST_COMMAND_LINE_FLAG = 'enable-video-player-chromecast-support';
+
+chrome.commandLinePrivate.hasSwitch(CAST_COMMAND_LINE_FLAG, function(result) {
+ if (!result)
+ return;
+
+ CastExtensionDiscoverer.findInstalledExtension(onCastExtensionFound);
+});
+
+function onCastExtensionFound(extensionId) {
+ if (!extensionId) {
+ console.info('Cast extention is not found.');
+ return;
+ }
+
+ var api = document.createElement('script');
+ api.src = 'chrome-extension://' + extensionId + '/api_script.js';
+ api.onload = function() {
+ initializeCast(extensionId);
+ };
+ api.onerror = function() {
+ console.error('api_script.js load failed.');
+ };
+ document.body.appendChild(api);
+};
+
+function initializeCast(extensionId) {
+ loadCastExtensionApi();
+
+ castApi = new cast.ExtensionApi(extensionId);
+ castApi.addReceiverListener('ChromeCast', onReceiverUpdate);
+}
+
+function onReceiverUpdate(receivers) {
+ player.setCastList(receivers);
+}

Powered by Google App Engine
This is Rietveld 408576698