Bug 1321631 - Delay loading RDM camera audio until used. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Mon, 31 Oct 2016 14:22:29 -0500
changeset 325054 6060c3c5634270024b22c7ef28f29063ce3e35fa
parent 325053 8ea964e7ab596c985f0b8d9ab86e251b64cadf49
child 325055 4dc3204e5c26b377ab17fe9dd2845408361fecc1
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersochameau
bugs1321631
milestone53.0a1
Bug 1321631 - Delay loading RDM camera audio until used. r=ochameau MozReview-Commit-ID: LWHS1xFRvdd
devtools/client/responsive.html/actions/screenshot.js
--- a/devtools/client/responsive.html/actions/screenshot.js
+++ b/devtools/client/responsive.html/actions/screenshot.js
@@ -11,17 +11,17 @@ const {
   TAKE_SCREENSHOT_END,
 } = require("./index");
 
 const { getFormatStr } = require("../utils/l10n");
 const { getToplevelWindow } = require("sdk/window/utils");
 const { Task: { spawn } } = require("devtools/shared/task");
 const e10s = require("../utils/e10s");
 
-const audioCamera = new window.Audio("resource://devtools/client/themes/audio/shutter.wav");
+const CAMERA_AUDIO_URL = "resource://devtools/client/themes/audio/shutter.wav";
 
 const animationFrame = () => new Promise(resolve => {
   window.requestAnimationFrame(resolve);
 });
 
 function getFileName() {
   let date = new Date();
   let month = ("0" + (date.getMonth() + 1)).substr(-2);
@@ -49,17 +49,18 @@ function saveToFile(data, filename) {
 
     chromeWindow.saveURL(data, filename, null,
                          true, true,
                          chromeDocument.documentURIObject, chromeDocument);
   });
 }
 
 function simulateCameraEffects(node) {
-  audioCamera.play();
+  let cameraAudio = new window.Audio(CAMERA_AUDIO_URL);
+  cameraAudio.play();
   node.animate({ opacity: [ 0, 1 ] }, 500);
 }
 
 module.exports = {
 
   takeScreenshot() {
     return function* (dispatch, getState) {
       yield dispatch({ type: TAKE_SCREENSHOT_START });