gokadzev / capacitor-music-controls-plugin-new

An update to Cordova Music Controls plugin to support Capacitor 3
9 stars 4 forks source link

Controls not showing #2

Closed mariusbolik closed 2 years ago

mariusbolik commented 2 years ago

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);
  }
}
gokadzev commented 2 years ago

@mariusbolik Hello, add duration property which is required now and it will be fixed :)

Like this:

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,
        duration : 0,
      }).then(() => {
        console.log('Media Session initialized');
      }).catch(e => {
        console.log(e);
      });
mariusbolik commented 2 years ago

Worked! Thank you!