From f89499047a564c9f3d55cb8fb6a2e20a91089749 Mon Sep 17 00:00:00 2001 From: Sebastiaan Pasma Date: Fri, 29 Jun 2018 15:11:34 +0200 Subject: [PATCH] Update sound to play on the screens they suppose to play only --- src/js/controllers/confirm.js | 4 +++- src/js/controllers/tab-receive.js | 5 ++++- src/js/services/soundService.js | 11 ++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 51c193d4a..f77e6db75 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -624,7 +624,9 @@ angular.module('copayApp.controllers').controller('confirmController', function( (processName == 'sendingTx' && !$scope.wallet.canSign() && !$scope.wallet.isPrivKeyExternal()) ) && !isOn) { $scope.sendStatus = 'success'; - soundService.play('misc/payment_sent.mp3'); + + if ($state.current.name === "tabs.send.confirm") // XX SP: Otherwise all open wallets on other devices play this sound if you have been in a send flow before on that device. + soundService.play('misc/payment_sent.mp3'); firebaseEventsService.logEvent('sent_bitcoin', { coin: $scope.wallet.coin }); $timeout(function() { $scope.$digest(); diff --git a/src/js/controllers/tab-receive.js b/src/js/controllers/tab-receive.js index 44db9b0bc..dcae37131 100644 --- a/src/js/controllers/tab-receive.js +++ b/src/js/controllers/tab-receive.js @@ -130,8 +130,11 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi } } $scope.paymentReceivedCoin = $scope.wallet.coin; - $scope.$apply(function () { + + if ($state.current.name === "tabs.receive") soundService.play('misc/payment_received.mp3'); + + $scope.$apply(function () { $scope.showingPaymentReceived = true; }); } diff --git a/src/js/services/soundService.js b/src/js/services/soundService.js index 20318883f..759789e21 100644 --- a/src/js/services/soundService.js +++ b/src/js/services/soundService.js @@ -13,9 +13,14 @@ angular.module('copayApp.services').service('soundService', function($log, $time configService.whenAvailable(function(config) { if (config.soundsEnabled) { if (platformInfo.isCordova) { - var p = window.location.pathname; - var device_path = p.substring(0, p.lastIndexOf('/')); - var audio = new Media(device_path + '/' + soundFile, + + if (platformInfo.isAndroid) { + var p = window.location.pathname; + var device_path = p.substring(0, p.lastIndexOf('/')); + soundFile = device_path + '/' + soundFile; + } + + var audio = new Media(soundFile, function () { $log.debug("playAudio(bch_sent):Audio Success"); },