spotube icon indicating copy to clipboard operation
spotube copied to clipboard

Feature Request

Open abhinavanand-fed opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

It would be good if the Discord rich presence resembles Spotify's rich presence. Not an exact copy, but there should be an option to showcase music playback from the user's profile.

spotify Spotube

Suggested solution

This might help you.

import 'dart:async';
import 'package:discord_rpc/discord_rpc.dart' as discord_rpc;

void main() {
  discord_rpc.initialize('YOUR_CLIENT_ID');

  // Define a custom URI that your application can handle
  final playButtonUri = 'yourmusicapp://play';

  discord_rpc.updatePresence(
    discord_rpc.Presence(
      details: 'Listening to Music',
      state: 'Song Title',
      largeImageKey: 'spotify',
      largeImageText: 'Your Software Name',
      buttons: [
        discord_rpc.Button(label: 'Play', url: playButtonUri),
      ],
    ),
  );

  // Optional: Set up a periodic timer to keep the presence updated
  Timer.periodic(Duration(seconds: 15), (timer) {
    discord_rpc.updatePresence(
      discord_rpc.Presence(
        details: 'Listening to Music',
        state: 'Song Title',
        largeImageKey: 'spotify',
        largeImageText: 'Your Software Name',
        buttons: [
          discord_rpc.Button(label: 'Play', url: playButtonUri),
        ],
      ),
    );
  });

  // Ensure to close the connection when your application exits
  // This is a simple console app example; in a real application, handle this properly
  // For web applications, use window.onUnload or similar
  ProcessSignal.sigint.watch().listen((_) {
    discord_rpc.shutdown();
    exit(0);
  });
}

  • Custom Link: The "Play" button in Discord sends a special link (e.g., yourmusicapp://play).

  • Your Software Setup: Your music software must be set up to recognize and respond when it receives this special link.

  • User Clicks "Play": Clicking "Play" on Discord opens the link.

  • Desired Action: Your music software, if properly configured, performs the desired action, like playing a specific song associated with the link.

Useful resources

No response

Additional information

No response

abhinavanand-fed avatar Jan 06 '24 08:01 abhinavanand-fed

Potential duplicates:

  • [#1000] Feature suggestions (63.64%)

github-actions[bot] avatar Jan 06 '24 08:01 github-actions[bot]

Potential duplicates:

  • [#1000] Feature suggestions (63.64%)

github-actions[bot] avatar Jan 06 '24 08:01 github-actions[bot]

Yeah,and maybe show the album cover,thats a so good extra

KaaaooS avatar Jan 08 '24 01:01 KaaaooS