Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/factories/media-manager.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
angular.module('ionic-audio').factory('MediaManager', ['$interval', '$timeout', '$window', function ($interval, $timeout, $window) {
var tracks = [], currentTrack, currentMedia, playerTimer;
var tracks = [], currentTrack, currentMedia, playerTimer, volume = 1;

if (!$window.cordova && !$window.Media) {
console.log("ionic-audio: missing Cordova Media plugin. Have you installed the plugin? \nRun 'ionic plugin add cordova-plugin-media'");
Expand All @@ -12,6 +12,7 @@ angular.module('ionic-audio').factory('MediaManager', ['$interval', '$timeout',
pause: pause,
stop: stop,
seekTo: seekTo,
setVolume: setVolume,
destroy: destroy
};

Expand Down Expand Up @@ -114,6 +115,7 @@ angular.module('ionic-audio').factory('MediaManager', ['$interval', '$timeout',

currentMedia = createMedia(currentTrack);
currentMedia.play();
setVolume(volume);

startTimer();
}
Expand All @@ -124,6 +126,14 @@ angular.module('ionic-audio').factory('MediaManager', ['$interval', '$timeout',
startTimer();
}

function setVolume(value) {
console.log('ionic-audio: change volume ' + value);
if (currentMedia) {
currentMedia.setVolume(value);
}
volume = value;
}

function stop() {
if (currentMedia){
console.log('ionic-audio: stopping track ' + currentTrack.title);
Expand Down Expand Up @@ -205,4 +215,4 @@ angular.module('ionic-audio').factory('MediaManager', ['$interval', '$timeout',

}, 1000);
}
}]);
}]);