Getting Started/Discord RPC Plugin

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) :( :o :-? 8) :lol: :x :P :oops: :cry: :evil: :roll: :wink:

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Getting Started/Discord RPC Plugin

Re: Getting Started/Discord RPC Plugin

by Garion525 » Fri Aug 24, 2018 6:08 pm

Let me know when you get this working, I have been looking everywhere for a plugin for MM and Discord.

Re: Getting Started/Discord RPC Plugin

by TIV73 » Sun Aug 12, 2018 10:35 am

From the looks of it you are going for a native implementation, but in case you still use the workaround via .net you might want to have a look at the github page for MediaMonkey.Net again. I just pushed several updates to the dev branch , which is pretty much a complete rewrite of the original plugin which and now uses an asynchronous implementation of most calls and offers event based updates to avoid having to constantly poll mediamonkey for updates.

Re: Getting Started/Discord RPC Plugin

by malkierian » Tue Jul 31, 2018 11:53 am

I will appreciate anything you can do, but if necessary, I will figure out how to interface with Discord directly, since it is open-source, and I probably only need certain aspects of the API.

Re: Getting Started/Discord RPC Plugin

by PetrCBR » Tue Jul 31, 2018 10:53 am

Hmm ... implement node.js core will not be easy ... it is using so much methods from native code of Node :-/.

Re: Getting Started/Discord RPC Plugin

by PetrCBR » Tue Jul 31, 2018 4:14 am

Hmm ... it will probably require to somehow include node runtime into script folder .. will try.

Re: Getting Started/Discord RPC Plugin

by malkierian » Mon Jul 30, 2018 7:02 pm

Alright, this is the folder that was created with the libraries and their prerequisites.

https://www.dropbox.com/s/4pm0aveljkj8z ... s.zip?dl=0

These were installed into the project using node/NPM.

Re: Getting Started/Discord RPC Plugin

by PetrCBR » Mon Jul 30, 2018 3:15 pm

I understand ... you can put them into folder together with your script, but question is how to load them (as we don't use any 3rd party scripts and we don't use require) and i can help with that if you need ... but i need any sample library you need to use in your script.

Re: Getting Started/Discord RPC Plugin

by malkierian » Mon Jul 30, 2018 2:56 pm

These are very specific to the Discord Rich Presence API. Only my addon would benefit from you including them in source. Which is why I asked about including them in the scripts folder.

Re: Getting Started/Discord RPC Plugin

by PetrCBR » Mon Jul 30, 2018 2:18 pm

We're not using 3rd party modules. If you can, send me some of them and will try how to include (petr at mediamonkey dot com).

Re: Getting Started/Discord RPC Plugin

by malkierian » Mon Jul 30, 2018 1:08 pm

Awesome, thanks.

Next question. Is it possible to load third-party libraries in the scripts system? Right now, I have a couple nested requirements I'm trying to load, but they use "require" instead of "requirejs" or "localRequirejs", and I get the error "require is not defined" at startup. Am I going to have to go through each of the source files on there to change those things, or is there some other way I should be doing it?

Re: Getting Started/Discord RPC Plugin

by PetrCBR » Mon Jul 30, 2018 3:11 am

Check controls/player.js.
Our app.player object have event you need. For example:

Code: Select all

function _onPlaybackState(state) {
  switch (state) {
    case 'unpause': ...
    case 'play': ...
    case 'stop': ...
    case 'pause': ...
    case 'trackChanged': ...
  }
};
app.listen(app.player, 'playbackState', _onPlaybackState);

Re: Getting Started/Discord RPC Plugin

by malkierian » Sun Jul 29, 2018 9:43 pm

Is there an event system? How would I tie into the play/pause/next/prev/etc functions? I would need to know when a track is paused, and when it plays (from whatever source, whether unpausing, going back or forward, or starting a new track through the media browser).

Re: Getting Started/Discord RPC Plugin

by PetrCBR » Sun Jul 29, 2018 3:57 pm

Feel free to ask anything about MM5 script development.

Re: Getting Started/Discord RPC Plugin

by malkierian » Sat Jul 28, 2018 8:00 pm

Thanks for that info, PetrCBR. Hopefully I can utilize it in a little while.

Just wanted to give an update, thanks to TIV73's MediaMonkeyNet, I was able to put together a C# utility that plugs into MM and feeds info to Discord:

https://i.imgur.com/sLU88VL.png

Unfortunately, they made the assumption that only games developers are going to want to use RPC, so this is as good as it will get until they decide to give us more extensibility/Spotify-like abilities through the API. I'm hoping I can figure out how to do this in JS so I can drop it in the scripts folder and have a setting for it in user preferences, but I have what I wanted for now, so that may be a while.

Re: Getting Started/Discord RPC Plugin

by PetrCBR » Fri Jul 27, 2018 3:30 am

Basically ... every folder (or zip file) in Scripts folder is single script. Script can just override/extend any of ours files/classes and can run his code at MM startup. When you need to extend any of our files (typically actions.js where all basic actions are located), just add file with "_add" name addition (e.g. actions_add.js) and this file will be automatically included at the end of our file. Script can contain init.js which is called at MM startup so can be used to register toolbar button(s) etc. If you need to add your item in track popup menu (right-click on track in any tracklist), check controls/trackListView.js file for window.menus.createTracklistMenu method (and window.menus.tracklistMenuItems array) which is called everytime user raise right-click on track. Easiest way how to add your action(s) to that menu is add "controls/trackListView_add.js" file into your script and add your action(s) to window.menus.tracklistMenuItems array.

Code: Select all

window.menus.tracklistMenuItems.push(
    {
        action: actions.myAction,
        order: 10,
        grouporder: 10
    });
Using order and grouporder you can define where in the list your action will be added.

Top