1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86// install : cordova plugin add https://github.com/sidneys/cordova-plugin-nativeaudio.git
// link : https://github.com/sidneys/cordova-plugin-nativeaudio
angular.module('ngCordova.plugins.nativeAudio', [])
.factory('$cordovaNativeAudio', ['$q', '$window', function ($q, $window) {
return {
preloadSimple: function (id, assetPath) {
var q = $q.defer();
$window.plugins.NativeAudio.preloadSimple(id, assetPath, function (result) {
q.resolve(result);
}, function (err) {
q.reject(err);
});
return q.promise;
},
preloadComplex: function (id, assetPath, volume, voices, delay) {
var q = $q.defer();
$window.plugins.NativeAudio.preloadComplex(id, assetPath, volume, voices, delay, function (result) {
q.resolve(result);
}, function (err) {
q.reject(err);
});
return q.promise;
},
play: function (id, completeCallback) {
var q = $q.defer();
$window.plugins.NativeAudio.play(id, function (result) {
q.resolve(result);
}, function (err) {
q.reject(err);
}, completeCallback);
return q.promise;
},
stop: function (id) {
var q = $q.defer();
$window.plugins.NativeAudio.stop(id, function (result) {
q.resolve(result);
}, function (err) {
q.reject(err);
});
return q.promise;
},
loop: function (id) {
var q = $q.defer();
$window.plugins.NativeAudio.loop(id, function (result) {
q.resolve(result);
}, function (err) {
q.reject(err);
});
return q.promise;
},
unload: function (id) {
var q = $q.defer();
$window.plugins.NativeAudio.unload(id, function (result) {
q.resolve(result);
}, function (err) {
q.reject(err);
});
return q.promise;
},
setVolumeForComplexAsset: function (id, volume) {
var q = $q.defer();
$window.plugins.NativeAudio.setVolumeForComplexAsset(id, volume, function (result) {
q.resolve(result);
}, function (err) {
q.reject(err);
});
return q.promise;
}
};
}]);