57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
angular.module('kinderspiel.services', [])
|
|
|
|
.factory("backgroundsounds_mediahandler", function($ionicPlatform, $cordovaMedia) {
|
|
|
|
/*
|
|
* Checkvariable ob App im Hintergrund ist
|
|
*/
|
|
var inbackground=false;
|
|
|
|
/*
|
|
* Soundfiles Variablen
|
|
*/
|
|
var backgroundmusic='';
|
|
$ionicPlatform.ready(function() {
|
|
var mybackground_music = new Media('/android_asset/www/sounds/TORN.MID', loopbackgroundmusic ,null);
|
|
backgroundmusic=mybackground_music;
|
|
});
|
|
|
|
|
|
function loopbackgroundmusic(){
|
|
if (inbackground == false){
|
|
backgroundmusic.release();
|
|
backgroundmusic=mybackground_music;
|
|
backgroundmusic.play();
|
|
backgroundmusic.setVolume('0.3');
|
|
}
|
|
}
|
|
|
|
|
|
return {
|
|
playbackgroundmusic: function() {
|
|
if (inbackground == false){
|
|
backgroundmusic.play();
|
|
backgroundmusic.setVolume('0.3');
|
|
}
|
|
},
|
|
stopbackgroundmusic: function() {
|
|
backgroundmusic.stop();
|
|
},
|
|
setbackgroundstate: function(mybool) {
|
|
inbackground=mybool;
|
|
},
|
|
getbackgroundstate: function() {
|
|
return inbackground;
|
|
}
|
|
};
|
|
})
|
|
|
|
.factory("kcSleep", function($timeout) {
|
|
return function(ms) {
|
|
return function(value) {
|
|
return $timeout(function() {
|
|
return value;
|
|
}, ms);
|
|
};
|
|
};
|
|
}); |