@capgo/capacitor-mute 1.1.8 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapgoCapacitorMute.podspec +1 -2
- package/README.md +31 -0
- package/android/build.gradle +9 -10
- package/android/src/main/java/ee/forgr/plugin/mute/MutePlugin.java +1 -1
- package/dist/docs.json +3 -1
- package/dist/esm/definitions.d.ts +3 -3
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.js +1 -1
- package/dist/plugin.cjs.js +2 -4
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2 -4
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/Assets/mute.aiff +0 -0
- package/ios/Plugin/Classes/Mute.swift +210 -0
- package/ios/Plugin/Muted.swift +0 -1
- package/package.json +19 -14
|
@@ -11,8 +11,7 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
13
|
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
-
s.ios.deployment_target = '
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
15
|
s.dependency 'Capacitor'
|
|
16
|
-
s.dependency 'Mute'
|
|
17
16
|
s.swift_version = '5.1'
|
|
18
17
|
end
|
package/README.md
CHANGED
|
@@ -14,6 +14,37 @@ npm install @capgo/capacitor-mute
|
|
|
14
14
|
npx cap sync
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
## Know issue
|
|
18
|
+
|
|
19
|
+
On IOS with Xcode 14 the lib use under the hood `Mute` is not configured as Apple expect anymore, it's not the only one having the issue as you can see here :
|
|
20
|
+
https://github.com/CocoaPods/CocoaPods/issues/8891
|
|
21
|
+
|
|
22
|
+
Solution:
|
|
23
|
+
Replace this to your Podfile:
|
|
24
|
+
```ruby
|
|
25
|
+
post_install do |installer|
|
|
26
|
+
assertDeploymentTarget(installer)
|
|
27
|
+
end
|
|
28
|
+
```
|
|
29
|
+
By
|
|
30
|
+
```ruby
|
|
31
|
+
post_install do |installer|
|
|
32
|
+
assertDeploymentTarget(installer)
|
|
33
|
+
installer.pods_project.targets.each do |target|
|
|
34
|
+
if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
|
|
35
|
+
target.build_configurations.each do |config|
|
|
36
|
+
config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
```
|
|
42
|
+
That should solve your issue.
|
|
43
|
+
I did open issue in the original repo to see if they can fix it:
|
|
44
|
+
https://github.com/akramhussein/Mute/issues/16
|
|
45
|
+
If no answer I will add the code directly to capacitor-mute
|
|
46
|
+
|
|
47
|
+
|
|
17
48
|
## API
|
|
18
49
|
|
|
19
50
|
<docgen-index>
|
package/android/build.gradle
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
ext {
|
|
2
|
-
junitVersion =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
|
|
4
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
|
|
5
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
repositories {
|
|
10
|
+
mavenCentral()
|
|
10
11
|
google()
|
|
11
|
-
jcenter()
|
|
12
12
|
}
|
|
13
13
|
dependencies {
|
|
14
|
-
classpath 'com.android.tools.build:gradle:
|
|
14
|
+
classpath 'com.android.tools.build:gradle:7.2.1'
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
apply plugin: 'com.android.library'
|
|
19
19
|
|
|
20
20
|
android {
|
|
21
|
-
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion :
|
|
21
|
+
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
|
|
22
22
|
defaultConfig {
|
|
23
|
-
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion :
|
|
24
|
-
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion :
|
|
23
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
24
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
|
|
25
25
|
versionCode 1
|
|
26
26
|
versionName "1.0"
|
|
27
27
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
@@ -43,7 +43,6 @@ android {
|
|
|
43
43
|
|
|
44
44
|
repositories {
|
|
45
45
|
google()
|
|
46
|
-
jcenter()
|
|
47
46
|
mavenCentral()
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -16,7 +16,7 @@ public class MutePlugin extends Plugin {
|
|
|
16
16
|
JSObject ret = new JSObject();
|
|
17
17
|
ret.put("value", true);
|
|
18
18
|
AudioManager audio = (AudioManager) this.bridge.getContext().getSystemService(Context.AUDIO_SERVICE);
|
|
19
|
-
switch (
|
|
19
|
+
switch (audio.getRingerMode()) {
|
|
20
20
|
case AudioManager.RINGER_MODE_NORMAL:
|
|
21
21
|
ret.put("value", false);
|
|
22
22
|
}
|
package/dist/docs.json
CHANGED
package/dist/esm/index.js
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,IAAI,GAAG,cAAc,CAAa,MAAM,EAAE;IAC9C,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,IAAI,GAAG,cAAc,CAAa,MAAM,EAAE;IAC9C,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;CACxD,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/dist/esm/web.js
CHANGED
package/dist/plugin.cjs.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
3
|
var core = require('@capacitor/core');
|
|
6
4
|
|
|
7
5
|
const Mute = core.registerPlugin('Mute', {
|
|
8
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.MuteWeb()),
|
|
6
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.MuteWeb()),
|
|
9
7
|
});
|
|
10
8
|
|
|
11
9
|
class MuteWeb extends core.WebPlugin {
|
|
12
10
|
async isMuted() {
|
|
13
11
|
console.log('isMuted');
|
|
14
|
-
throw new Error(
|
|
12
|
+
throw new Error('Method not implemented.');
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
15
|
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Mute = registerPlugin('Mute', {\n web: () => import('./web').then(m => new m.MuteWeb()),\n});\nexport * from './definitions';\nexport { Mute };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MuteWeb extends WebPlugin {\n async isMuted() {\n console.log('isMuted');\n throw new Error(
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Mute = registerPlugin('Mute', {\n web: () => import('./web').then((m) => new m.MuteWeb()),\n});\nexport * from './definitions';\nexport { Mute };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MuteWeb extends WebPlugin {\n async isMuted() {\n console.log('isMuted');\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;AACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;AAC3D,CAAC;;ACFM,MAAM,OAAO,SAASC,cAAS,CAAC;AACvC,IAAI,MAAM,OAAO,GAAG;AACpB,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;AACnD,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -2,13 +2,13 @@ var capacitorMute = (function (exports, core) {
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
const Mute = core.registerPlugin('Mute', {
|
|
5
|
-
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.MuteWeb()),
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.MuteWeb()),
|
|
6
6
|
});
|
|
7
7
|
|
|
8
8
|
class MuteWeb extends core.WebPlugin {
|
|
9
9
|
async isMuted() {
|
|
10
10
|
console.log('isMuted');
|
|
11
|
-
throw new Error(
|
|
11
|
+
throw new Error('Method not implemented.');
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -19,8 +19,6 @@ var capacitorMute = (function (exports, core) {
|
|
|
19
19
|
|
|
20
20
|
exports.Mute = Mute;
|
|
21
21
|
|
|
22
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
23
|
-
|
|
24
22
|
return exports;
|
|
25
23
|
|
|
26
24
|
})({}, capacitorExports);
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Mute = registerPlugin('Mute', {\n web: () => import('./web').then(m => new m.MuteWeb()),\n});\nexport * from './definitions';\nexport { Mute };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MuteWeb extends WebPlugin {\n async isMuted() {\n console.log('isMuted');\n throw new Error(
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Mute = registerPlugin('Mute', {\n web: () => import('./web').then((m) => new m.MuteWeb()),\n});\nexport * from './definitions';\nexport { Mute };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class MuteWeb extends WebPlugin {\n async isMuted() {\n console.log('isMuted');\n throw new Error('Method not implemented.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,IAAI,GAAGA,mBAAc,CAAC,MAAM,EAAE;IACpC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3D,CAAC;;ICFM,MAAM,OAAO,SAASC,cAAS,CAAC;IACvC,IAAI,MAAM,OAAO,GAAG;IACpB,QAAQ,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACnD,KAAK;IACL;;;;;;;;;;;;;;;"}
|
|
Binary file
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Mute.swift
|
|
3
|
+
// Mute
|
|
4
|
+
//
|
|
5
|
+
// Created by Akram Hussein on 08/09/2017.
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import AudioToolbox
|
|
10
|
+
import UIKit
|
|
11
|
+
|
|
12
|
+
@objcMembers
|
|
13
|
+
public class Mute: NSObject {
|
|
14
|
+
|
|
15
|
+
public typealias MuteNotificationCompletion = ((_ mute: Bool) -> Void)
|
|
16
|
+
|
|
17
|
+
// MARK: Properties
|
|
18
|
+
|
|
19
|
+
/// Shared instance
|
|
20
|
+
public static let shared = Mute()
|
|
21
|
+
|
|
22
|
+
/// Sound ID for mute sound
|
|
23
|
+
private let soundUrl = Mute.muteSoundUrl
|
|
24
|
+
|
|
25
|
+
/// Should notify every second or only when changes?
|
|
26
|
+
/// True will notify every second of the state, false only when it changes
|
|
27
|
+
public var alwaysNotify = true
|
|
28
|
+
|
|
29
|
+
/// Notification handler to be triggered when mute status changes
|
|
30
|
+
/// Triggered every second if alwaysNotify=true, otherwise only when it switches state
|
|
31
|
+
public var notify: MuteNotificationCompletion?
|
|
32
|
+
|
|
33
|
+
/// Currently playing? used when returning from the background (if went to background and foreground really quickly)
|
|
34
|
+
public private(set) var isPlaying = false
|
|
35
|
+
|
|
36
|
+
/// Current mute state
|
|
37
|
+
public private(set) var isMute = false
|
|
38
|
+
|
|
39
|
+
/// Sound is scheduled
|
|
40
|
+
private var isScheduled = false
|
|
41
|
+
|
|
42
|
+
/// State of detection - paused when in background
|
|
43
|
+
public var isPaused = false {
|
|
44
|
+
didSet {
|
|
45
|
+
if !self.isPaused && oldValue && !self.isPlaying {
|
|
46
|
+
self.schedulePlaySound()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// How frequently to check (seconds), minimum = 0.5
|
|
52
|
+
public var checkInterval = 1.0 {
|
|
53
|
+
didSet {
|
|
54
|
+
if self.checkInterval < 0.5 {
|
|
55
|
+
print("MUTE: checkInterval cannot be less than 0.5s, setting to 0.5")
|
|
56
|
+
self.checkInterval = 0.5
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/// Silent sound (0.5 sec)
|
|
62
|
+
private var soundId: SystemSoundID = 0
|
|
63
|
+
|
|
64
|
+
/// Time difference between start and finish of mute sound
|
|
65
|
+
private var interval: TimeInterval = 0
|
|
66
|
+
|
|
67
|
+
// MARK: Resources
|
|
68
|
+
|
|
69
|
+
/// Library bundle
|
|
70
|
+
private static var bundle: Bundle {
|
|
71
|
+
if let path = Bundle(for: Mute.self).path(forResource: "Mute", ofType: "bundle"),
|
|
72
|
+
let bundle = Bundle(path: path) {
|
|
73
|
+
return bundle
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let spmBundleName = "Mute_Mute"
|
|
77
|
+
|
|
78
|
+
let candidates = [
|
|
79
|
+
// Bundle should be present here when the package is linked into an App.
|
|
80
|
+
Bundle.main.resourceURL,
|
|
81
|
+
|
|
82
|
+
// Bundle should be present here when the package is linked into a framework.
|
|
83
|
+
Bundle(for: Mute.self).resourceURL
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
for candidate in candidates {
|
|
87
|
+
let bundlePath = candidate?.appendingPathComponent(spmBundleName + ".bundle")
|
|
88
|
+
if let bundle = bundlePath.flatMap(Bundle.init(url:)) {
|
|
89
|
+
return bundle
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
fatalError("Mute.bundle not found")
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/// Mute sound url path
|
|
97
|
+
private static var muteSoundUrl: URL {
|
|
98
|
+
guard let muteSoundUrl = Mute.bundle.url(forResource: "mute", withExtension: "aiff") else {
|
|
99
|
+
fatalError("mute.aiff not found")
|
|
100
|
+
}
|
|
101
|
+
return muteSoundUrl
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// MARK: Init
|
|
105
|
+
|
|
106
|
+
/// private init
|
|
107
|
+
override private init() {
|
|
108
|
+
super.init()
|
|
109
|
+
|
|
110
|
+
self.soundId = 1
|
|
111
|
+
|
|
112
|
+
if AudioServicesCreateSystemSoundID(self.soundUrl as CFURL, &self.soundId) == kAudioServicesNoError {
|
|
113
|
+
var yes: UInt32 = 1
|
|
114
|
+
AudioServicesSetProperty(kAudioServicesPropertyIsUISound,
|
|
115
|
+
UInt32(MemoryLayout.size(ofValue: self.soundId)),
|
|
116
|
+
&self.soundId,
|
|
117
|
+
UInt32(MemoryLayout.size(ofValue: yes)),
|
|
118
|
+
&yes)
|
|
119
|
+
|
|
120
|
+
self.schedulePlaySound()
|
|
121
|
+
} else {
|
|
122
|
+
print("Failed to setup sound player")
|
|
123
|
+
self.soundId = 0
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Notifications
|
|
127
|
+
NotificationCenter.default.addObserver(self,
|
|
128
|
+
selector: #selector(Mute.didEnterBackground(_:)),
|
|
129
|
+
name: UIApplication.didEnterBackgroundNotification,
|
|
130
|
+
object: nil)
|
|
131
|
+
|
|
132
|
+
NotificationCenter.default.addObserver(self,
|
|
133
|
+
selector: #selector(Mute.willEnterForeground(_:)),
|
|
134
|
+
name: UIApplication.willEnterForegroundNotification,
|
|
135
|
+
object: nil)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
deinit {
|
|
139
|
+
if self.soundId != 0 {
|
|
140
|
+
AudioServicesRemoveSystemSoundCompletion(self.soundId)
|
|
141
|
+
AudioServicesDisposeSystemSoundID(self.soundId)
|
|
142
|
+
}
|
|
143
|
+
NotificationCenter.default.removeObserver(self)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// MARK: Notification Handlers
|
|
147
|
+
|
|
148
|
+
/// Selector called when app enters background
|
|
149
|
+
@objc private func didEnterBackground(_ sender: Any) {
|
|
150
|
+
self.isPaused = true
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// Selector called when app will enter foreground
|
|
154
|
+
@objc private func willEnterForeground(_ sender: Any) {
|
|
155
|
+
self.isPaused = false
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// MARK: Methods
|
|
159
|
+
|
|
160
|
+
/// Starts a mute check outside the `checkInterval`
|
|
161
|
+
public func check() {
|
|
162
|
+
self.playSound()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/// Schedules mute sound to be played at `checkInterval`
|
|
166
|
+
private func schedulePlaySound() {
|
|
167
|
+
/// Don't schedule a new one if we already have one queued
|
|
168
|
+
if self.isScheduled { return }
|
|
169
|
+
|
|
170
|
+
self.isScheduled = true
|
|
171
|
+
|
|
172
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + self.checkInterval) {
|
|
173
|
+
self.isScheduled = false
|
|
174
|
+
|
|
175
|
+
/// Don't play if we're paused
|
|
176
|
+
if self.isPaused {
|
|
177
|
+
return
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
self.playSound()
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/// If not paused, playes mute sound
|
|
185
|
+
private func playSound() {
|
|
186
|
+
if !self.isPaused && !self.isPlaying {
|
|
187
|
+
self.interval = Date.timeIntervalSinceReferenceDate
|
|
188
|
+
self.isPlaying = true
|
|
189
|
+
AudioServicesPlaySystemSoundWithCompletion(self.soundId) { [weak self] in
|
|
190
|
+
self?.soundFinishedPlaying()
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/// Called when AudioService finished playing sound
|
|
196
|
+
private func soundFinishedPlaying() {
|
|
197
|
+
self.isPlaying = false
|
|
198
|
+
|
|
199
|
+
let elapsed = Date.timeIntervalSinceReferenceDate - self.interval
|
|
200
|
+
let isMute = elapsed < 0.1
|
|
201
|
+
|
|
202
|
+
if self.isMute != isMute || self.alwaysNotify {
|
|
203
|
+
self.isMute = isMute
|
|
204
|
+
DispatchQueue.main.async {
|
|
205
|
+
self.notify?(isMute)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
self.schedulePlaySound()
|
|
209
|
+
}
|
|
210
|
+
}
|
package/ios/Plugin/Muted.swift
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-mute",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"description": "Detect if the mute switch is enabled/disabled on a device",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
31
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
32
|
-
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin && cd ..",
|
|
32
|
+
"verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -sdk iphoneos -scheme Plugin && cd ..",
|
|
33
33
|
"verify:android": "cd android && ./gradlew clean build test && cd ..",
|
|
34
34
|
"verify:web": "npm run build",
|
|
35
35
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
@@ -38,29 +38,34 @@
|
|
|
38
38
|
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
39
39
|
"swiftlint": "node-swiftlint",
|
|
40
40
|
"docgen": "docgen --api MutePlugin --output-readme README.md --output-json dist/docs.json",
|
|
41
|
-
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.
|
|
41
|
+
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
42
42
|
"clean": "rimraf ./dist",
|
|
43
43
|
"watch": "tsc --watch",
|
|
44
44
|
"prepublishOnly": "npm run build"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@capacitor/android": "^
|
|
48
|
-
"@capacitor/
|
|
49
|
-
"@capacitor/
|
|
50
|
-
"@capacitor/
|
|
47
|
+
"@capacitor/android": "^4.4.0",
|
|
48
|
+
"@capacitor/cli": "^4.4.0",
|
|
49
|
+
"@capacitor/core": "^4.4.0",
|
|
50
|
+
"@capacitor/docgen": "^0.2.0",
|
|
51
|
+
"@capacitor/ios": "^4.4.0",
|
|
51
52
|
"@ionic/eslint-config": "^0.3.0",
|
|
52
|
-
"@ionic/prettier-config": "^
|
|
53
|
+
"@ionic/prettier-config": "^2.0.0",
|
|
53
54
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
54
|
-
"eslint": "^
|
|
55
|
-
"
|
|
56
|
-
"
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
|
56
|
+
"@typescript-eslint/parser": "^5.42.1",
|
|
57
|
+
"eslint": "^8.27.0",
|
|
58
|
+
"eslint-plugin-import": "^2.26.0",
|
|
59
|
+
"husky": "^8.0.2",
|
|
60
|
+
"prettier": "^2.7.1",
|
|
61
|
+
"prettier-plugin-java": "^1.6.2",
|
|
57
62
|
"rimraf": "^3.0.2",
|
|
58
|
-
"rollup": "^2.
|
|
63
|
+
"rollup": "^3.2.5",
|
|
59
64
|
"swiftlint": "^1.0.1",
|
|
60
|
-
"typescript": "
|
|
65
|
+
"typescript": "^4.8.4"
|
|
61
66
|
},
|
|
62
67
|
"peerDependencies": {
|
|
63
|
-
"@capacitor/core": "^
|
|
68
|
+
"@capacitor/core": "^4.0.0"
|
|
64
69
|
},
|
|
65
70
|
"prettier": "@ionic/prettier-config",
|
|
66
71
|
"swiftlint": "@ionic/swiftlint-config",
|