diff --git a/CHANGELOG.md b/CHANGELOG.md index f45e6cc..ac17b8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v1.2.4 + +- fixed bug where pause button was disabled and was not possible to stop playback + ## v1.2.3 - fixed slider bug to allow seeking-to when track is paused diff --git a/bower.json b/bower.json index fc6f66d..e85772c 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "ionic-audio", "description": "Ionic UI for the Cordova Media Plugin", - "version": "1.2.3", + "version": "1.2.4", "homepage": "https://github.com/arielfaur/ionic-audio.git", "license": "MIT", "private": false, @@ -11,6 +11,6 @@ "angular-mocks": "~1.3.x" }, "devDependencies": { - "ionic": "driftyco/ionic-bower#1.0.0-rc.5" + "ionic": "driftyco/ionic-bower#1.0.1" } } diff --git a/dist/ion-audio.js b/dist/ion-audio.js index 38c37d9..5661c3a 100644 --- a/dist/ion-audio.js +++ b/dist/ion-audio.js @@ -284,7 +284,7 @@ angular.module('ionic-audio', ['ionic']) restrict: 'EA', scope: {}, require: ['ionAudioControls', '^^ionAudioTrack'], - controller: ['$scope', '$element', '$attrs', function($scope, $element, $attrs) { + controller: ['$scope', '$element', function($scope, $element) { var spinnerElem = $element.find('ion-spinner'), hasLoaded, self = this; spinnerElem.addClass('ng-hide'); @@ -334,19 +334,21 @@ angular.module('ionic-audio', ['ionic']) }]) .directive('ionAudioPlay', [function() { return { - scope: true, + //scope: true, restrict: 'A', require: '^^ionAudioControls', link: function(scope, element, attrs, controller) { + var isLoading, currentStatus = 0; var init = function() { + isLoading = false; element.addClass('ion-play'); element.removeClass('ion-pause'); element.text(attrs.textPlay); }; var setText = function() { - if (!attrs.textPlay || !attrs.textPause) return ''; + if (!attrs.textPlay || !attrs.textPause) return; element.text((element.text() == attrs.textPlay ? attrs.textPause : attrs.textPlay)); }; @@ -357,22 +359,22 @@ angular.module('ionic-audio', ['ionic']) }; element.on('click', function() { - element.prop('disabled', true); - // call main directive's play method + if (isLoading) return; // debounce multiple clicks + controller.playTrack(); togglePlaying(); + if (currentStatus == 0) isLoading = true; }); var unbindStatusListener = scope.$watch('track.status', function (status) { // Media.MEDIA_NONE or Media.MEDIA_STOPPED if (status == 0 || status == 4) { init(); + } else if (status == 2) { // Media.MEDIA_RUNNING + isLoading = false; } - // Media.MEDIA_RUNNING or Media.MEDIA_PAUSED - if (status == 2 || status == 3) { - element.prop('disabled', false); - } + currentStatus = status; }); init(); @@ -417,8 +419,9 @@ angular.module('ionic-audio', ['ionic']) return { visibility: angular.isDefined(attrs.displayInfo) && (scope.track.title || scope.track.artist) ? 'visible' : 'hidden'} }; - // disable slider if track hasn't loaded + // disable slider if track is not playing var unbindStatusListener = scope.$watch('track.status', function(status) { + // disable if track hasn't loaded slider.prop('disabled', status == 0); // Media.MEDIA_NONE }); @@ -443,7 +446,6 @@ angular.module('ionic-audio', ['ionic']) if (angular.isDefined(unbindTrackListener)) { unbindTrackListener(); } - MediaManager.destroy(); }); } } diff --git a/example-audio/bower.json b/example-audio/bower.json index 794c891..ff018bf 100644 --- a/example-audio/bower.json +++ b/example-audio/bower.json @@ -2,7 +2,7 @@ "name": "example-audio", "private": "true", "devDependencies": { - "ionic": "driftyco/ionic-bower#1.0.0-rc.5" + "ionic": "driftyco/ionic-bower#1.0.1" }, "dependencies": { "ngCordova": "*" diff --git a/example-audio/www/js/ion-audio.js b/example-audio/www/js/ion-audio.js index 38c37d9..5661c3a 100644 --- a/example-audio/www/js/ion-audio.js +++ b/example-audio/www/js/ion-audio.js @@ -284,7 +284,7 @@ angular.module('ionic-audio', ['ionic']) restrict: 'EA', scope: {}, require: ['ionAudioControls', '^^ionAudioTrack'], - controller: ['$scope', '$element', '$attrs', function($scope, $element, $attrs) { + controller: ['$scope', '$element', function($scope, $element) { var spinnerElem = $element.find('ion-spinner'), hasLoaded, self = this; spinnerElem.addClass('ng-hide'); @@ -334,19 +334,21 @@ angular.module('ionic-audio', ['ionic']) }]) .directive('ionAudioPlay', [function() { return { - scope: true, + //scope: true, restrict: 'A', require: '^^ionAudioControls', link: function(scope, element, attrs, controller) { + var isLoading, currentStatus = 0; var init = function() { + isLoading = false; element.addClass('ion-play'); element.removeClass('ion-pause'); element.text(attrs.textPlay); }; var setText = function() { - if (!attrs.textPlay || !attrs.textPause) return ''; + if (!attrs.textPlay || !attrs.textPause) return; element.text((element.text() == attrs.textPlay ? attrs.textPause : attrs.textPlay)); }; @@ -357,22 +359,22 @@ angular.module('ionic-audio', ['ionic']) }; element.on('click', function() { - element.prop('disabled', true); - // call main directive's play method + if (isLoading) return; // debounce multiple clicks + controller.playTrack(); togglePlaying(); + if (currentStatus == 0) isLoading = true; }); var unbindStatusListener = scope.$watch('track.status', function (status) { // Media.MEDIA_NONE or Media.MEDIA_STOPPED if (status == 0 || status == 4) { init(); + } else if (status == 2) { // Media.MEDIA_RUNNING + isLoading = false; } - // Media.MEDIA_RUNNING or Media.MEDIA_PAUSED - if (status == 2 || status == 3) { - element.prop('disabled', false); - } + currentStatus = status; }); init(); @@ -417,8 +419,9 @@ angular.module('ionic-audio', ['ionic']) return { visibility: angular.isDefined(attrs.displayInfo) && (scope.track.title || scope.track.artist) ? 'visible' : 'hidden'} }; - // disable slider if track hasn't loaded + // disable slider if track is not playing var unbindStatusListener = scope.$watch('track.status', function(status) { + // disable if track hasn't loaded slider.prop('disabled', status == 0); // Media.MEDIA_NONE }); @@ -443,7 +446,6 @@ angular.module('ionic-audio', ['ionic']) if (angular.isDefined(unbindTrackListener)) { unbindTrackListener(); } - MediaManager.destroy(); }); } } diff --git a/package.json b/package.json index 798eaa8..4572f83 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ionic-audio", "private": false, - "version": "1.2.3", + "version": "1.2.4", "description": "Ionic UI for the Cordova Media Plugin", "repository": "https://github.com/arielfaur/ionic-audio.git", "license": "MIT",