gokadzev / capacitor-music-controls-plugin-new Goto Github PK
View Code? Open in Web Editor NEWAn update to Cordova Music Controls plugin to support Capacitor 3
An update to Cordova Music Controls plugin to support Capacitor 3
How can I pause the player controls? It says that updateElapsed()
and updatePlaying()
are not implemented on android. Also the controls are not destroyed if the user ends the app.
Hello I am getting following error:
..../app/node_modules/capacitor-music-controls-plugin-new/android/src/main/java/com/gokadzev/capacitormusiccontrols/MusicControlsNotification.java:256: error: cannot find symbol
resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_MUTABLE);
^
symbol: variable FLAG_MUTABLE
location: class android.app.PendingIntent
Do you know what is causing the issue and how to fix that?
Hi, i am trying this plugin with capacitor 4.
I can install it but when i add the code to the MainActivity.java it gives me the problem:
Cannot resolve symbol gokadzev.
How can i add this dependency?
Hello, thank you for this plugin. Sadly, the controls aren't showing on my Android (8.1.0) Device. This is how I use the plugin:
import { CapacitorMusicControls } from 'capacitor-music-controls-plugin-new';
...
CapacitorMusicControls.create({
track: 'Lorem Ipsum',
ticker: 'Lorem Ipsum',
artist: 'Lorem Ipsum',
album: 'Lorem Ipsum',
cover: 'https://dummyimage.com/300/09f/fff.png',
hasPrev: false,
hasNext: false,
hasSkipForward: true,
hasSkipBackward: true,
skipForwardInterval : 15,
skipBackwardInterval : 15,
hasScrubbing: true,
isPlaying : true,
dismissable : false,
}).then(() => {
console.log('Media Session initialized');
}).catch(e => {
console.log(e);
});
AndroidManifest.xml
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
MainActivity.java
import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.gokadzev.capacitormusiccontrols.CapacitorMusicControls;
public class MainActivity extends BridgeActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Additional plugins you've installed go here
registerPlugin(CapacitorMusicControls.class);
}
}
I'm using Angular 12 with Capacitor and this Plugin, set the compileSdkVersion and targetSdkVersion to 31 in variables.gradle (I prefer not to put them to 31 as this can cause a lot of issues down the line). When I start the app on Android I get this error:
Caused by: java.lang.IllegalArgumentException: ch.pomona.newsapp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:632)
at com.gokadzev.capacitormusiccontrols.MusicControlsNotification.createBuilder(MusicControlsNotification.java:209)
at com.gokadzev.capacitormusiccontrols.MusicControlsNotification.updateNotification(MusicControlsNotification.java:81)
at com.gokadzev.capacitormusiccontrols.CapacitorMusicControls.updateMetadata(CapacitorMusicControls.java:224)
at com.gokadzev.capacitormusiccontrols.CapacitorMusicControls.create(CapacitorMusicControls.java:42)
... 9 more
I solved it by reverting back to API level 30 instead of 31 and forcing the androidx.appcompat dependency to version 1.2.0 (instead of 1.4.2 that will be picked otherwise):
in your app/build.gradle:
dependencies {
implementation("androidx.appcompat:appcompat:$androidxAppCompatVersion") {
force = true
}
}
Looks like the Bluetooth control events for pause, play, skip song etc are not firing on Android.
For the pause play events i'd suggest trying to request audio focus when the events are fired, and for the skip song (i.e if I double tab play pause on most headphones it triggers the next event on most app), it's likely this was never implemented in the original project.
I've done some experimentation around the above so let me know if you need pointing in the right direction ๐
Running the app on an iPhone 5s simulator with iOS 12.4 produces the following runtime error in Xcode:
Fatal error: Unexpectedly found nil while unwrapping an Optional value: file CapacitorMusicControlsPluginNew/Plugin.swift, line 175
2022-07-11 13:29:20.835727+0200 App[75764:805906] Fatal error: Unexpectedly found nil while unwrapping an Optional value: file CapacitorMusicControlsPluginNew/Plugin.swift, line 175
concerning the following Code:
if(urlPath != nil && defaultManager.fileExists(atPath: urlPath!)){
coverImage = UIImage(contentsOfFile: urlPath!)! // <- issue is this null-safety operator on UIImage()
} else {
coverImage = nil;
}
I guess iPhones of older architecture are handling null safety differently or not at all. Is there a way to handle this without the app crashing?
Just an FYI, currently getting:
[error] Analyzing dependencies
[!] No podspec found for `CapacitorMusicControlsPluginNew` in
`../../node_modules/.pnpm/github.com+gokadzev+capacitor-music-controls-plugin-new@2c3937e8e77cb50775269b6ddfa153c9a41b9b96/node_modules/capacitor-music-controls-plugin-new`
When running cap sync.
Hello, the app crashes on my Samsung A52S when I call the Plugin. In Android Studio it says
WebContentsDelegate::CheckMediaAccessPermission: Not supported.
After adding <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
to AndroidManifest it says:
E/Capacitor: Serious error executing plugin
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:121)
at com.getcapacitor.Bridge.lambda$callPluginMethod$0$com-getcapacitor-Bridge(Bridge.java:598)
at com.getcapacitor.Bridge$$ExternalSyntheticLambda5.run(Unknown Source:8)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.os.HandlerThread.run(HandlerThread.java:67)
Caused by: java.lang.IllegalArgumentException: de.btcecho.app: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
at android.app.PendingIntent.checkFlags(PendingIntent.java:382)
at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673)
at android.app.PendingIntent.getBroadcast(PendingIntent.java:660)
at com.gokadzev.capacitormusiccontrols.MusicControlsNotification.createBuilder(MusicControlsNotification.java:209)
at com.gokadzev.capacitormusiccontrols.MusicControlsNotification.updateNotification(MusicControlsNotification.java:81)
at com.gokadzev.capacitormusiccontrols.CapacitorMusicControls.updateMetadata(CapacitorMusicControls.java:224)
at com.gokadzev.capacitormusiccontrols.CapacitorMusicControls.create(CapacitorMusicControls.java:42)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.