Commit 1a19f560 authored by Randy Rossi's avatar Randy Rossi Committed by Commit Bot

Guard chrome.audio usage with check

chrome.audio is not available on chromecast. This caused
the background script to stop working.  Adding a guard
to make sure the api is available before use.

Test: Manual
Bug: 903924
Change-Id: I9f162d2f80074e72e44deca6d2893255fff37d2e
Reviewed-on: https://chromium-review.googlesource.com/c/1330220
Commit-Queue: Randy Rossi <rmrossi@chromium.org>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609319}
parent 04942507
...@@ -36,11 +36,15 @@ NextEarcons = function() { ...@@ -36,11 +36,15 @@ NextEarcons = function() {
/** @private {boolean} */ /** @private {boolean} */
this.shouldPan_ = true; this.shouldPan_ = true;
chrome.audio.getDevices( if (chrome.audio) {
{isActive: true, streamTypes: [chrome.audio.StreamType.OUTPUT]}, chrome.audio.getDevices(
this.updateShouldPanForDevices_.bind(this)); {isActive: true, streamTypes: [chrome.audio.StreamType.OUTPUT]},
chrome.audio.onDeviceListChanged.addListener( this.updateShouldPanForDevices_.bind(this));
this.updateShouldPanForDevices_.bind(this)); chrome.audio.onDeviceListChanged.addListener(
this.updateShouldPanForDevices_.bind(this));
} else {
this.shouldPan_ = false;
}
}; };
NextEarcons.prototype = { NextEarcons.prototype = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment