Merge pull request #178 from Bitcoin-com/wallet/task/379

Improvement - 379 - Coin sounds on "Payment received" screen
This commit is contained in:
Brendon Duncan 2018-06-19 21:52:39 +12:00 committed by GitHub
commit 06adfc5f44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 2 deletions

View file

@ -72,6 +72,7 @@
<plugin name="cordova-plugin-queries-schemes" spec="~0.1.5" />
<plugin name="cordova-plugin-firebase" spec="https://github.com/arnesson/cordova-plugin-firebase.git" />
<plugin name="cordova-plugin-wkwebview-inputfocusfix" spec="https://github.com/onderceylan/cordova-plugin-wkwebview-inputfocusfix.git" />
<plugin name="cordova-plugin-nativeaudio" spec="^3.0.9" />
<!-- Changes in error descriptions may break the use of cordova-plugin-secure-storage -->
<plugin name="cordova-plugin-secure-storage" spec="2.6.8" />
<!-- Supported Platforms -->

View file

@ -13,6 +13,24 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
var currentAddressSocket = {};
var paymentSubscriptionObj = { op:"addr_sub" }
var config;
var soundLoaded = false;
var nativeAudioAvailable = (window.plugins && window.plugins.NativeAudio);
if (nativeAudioAvailable) {
window.plugins.NativeAudio.preloadSimple('received', 'misc/coin_received.mp3', function (msg) {
$log.debug('Receive sound loaded.');
soundLoaded = true;
}, function (error) {
$log.debug('Error loading receive sound.');
$log.debug(error);
});
} else {
$log.debug('isNW: Using HTML5-Audio instead of native audio');
soundLoaded = true;
}
$scope.displayBalanceAsFiat = true;
$scope.requestSpecificAmount = function() {
@ -129,6 +147,17 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
}
$scope.paymentReceivedCoin = $scope.wallet.coin;
$scope.$apply(function () {
if (config.soundsEnabled && soundLoaded) {
$log.debug('Play sound.');
if (nativeAudioAvailable) {
window.plugins.NativeAudio.play('received');
} else {
new Audio('misc/coin_received.ogg').play(); // NW.js has no mp3 support
}
} else {
$log.debug('Sound is disabled.');
}
$scope.showingPaymentReceived = true;
});
}
@ -215,8 +244,9 @@ angular.module('copayApp.controllers').controller('tabReceiveController', functi
})
];
configService.whenAvailable(function(config) {
$scope.displayBalanceAsFiat = config.wallet.settings.priceDisplay === 'fiat';
configService.whenAvailable(function(_config) {
$scope.displayBalanceAsFiat = _config.wallet.settings.priceDisplay === 'fiat';
config = _config;
});
});

BIN
www/misc/coin_received.mp3 Normal file

Binary file not shown.

BIN
www/misc/coin_received.ogg Normal file

Binary file not shown.