Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

MediaMonkey

Questions and comments specific to a particular plugin should go here.
Alink
Posts: 12
Joined: Mon Dec 10, 2007 6:23 pm

Re: MediaMonkey

Post by Alink »

Bitmonster wrote:Well, this is problematic. Normally Python releases the dispatch to the COM object as soon as every reference to the COM object is deleted. So you can do something like:

del self.MM
self.MM = None

The problem is, that we don't know when MediaMonkey wants to close, as we have no direct event callback. One possibility might be to get and release the dispatch on every command.

Code: Select all

def DoCommand(command):
    mm = Dispatch("SongsDB.SDBApplication")
    getattr(mm.Player, command)()
    del mm

DoCommand("Play")
Oh yes, del was exactly what I was looking for.

We actually do have an event callback, via Pako's MediaMonkey autoscript (in this case Main.MM_finishing would be the one). So that could actually work.

Releasing the dispatch on every command works! That is unless the dispatch started the MediaMonkey application - then Mediamonkey will close on every command. :roll:

EDIT: My bad. I forgot the ShutdownAfterDisconnect=False. It works like a charm! Thank you, guys! :D
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: MediaMonkey

Post by Bitmonster »

You have to set a flag, to avoid the shutdown after the command. I just used this:

Code: Select all

from win32com.client.gencache import EnsureDispatch

def DoCommand(command):
    mm = EnsureDispatch("SongsDB.SDBApplication")
    mm.ShutdownAfterDisconnect=False
    getattr(mm.Player, command)()
    del mm

DoCommand("Play")
EnsureDispatch creates Python files inside a folder in Application Data/EventGhost/gen_py with an odd name. There you find all methods that are exposed by MM. They also have an event interface ISDBApplicationEvents which exposes the events:

# def OnSeek(self):
# def OnChangedSelection(self):
# def OnShutdown(self):
# def OnBeforeTracksMove(self, Tracks=defaultNamedNotOptArg, NewPaths=defaultNamedNotOptArg, IsMove=defaultNamedNotOptArg):
# def OnPlay(self):
# def OnPause(self):
# def OnStop(self):
# def OnTrackProperties(self, TrackList=defaultNamedNotOptArg):
# def OnTrackConverted(self, SourceTrack=defaultNamedNotOptArg, TargetTrack=defaultNamedNotOptArg):
# def OnTrackAdded(self, NewTrack=defaultNamedNotOptArg):

So this might be the way to go, by using DispatchWithEvents(). Then the .VBS might be also obsolete.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
User avatar
Bitmonster
Site Admin
Posts: 2239
Joined: Mon Feb 06, 2006 10:28 pm

Re: MediaMonkey

Post by Bitmonster »

One plugin that works in a similiar way is the DVBViewer plugin. It has an option to switch between SendMessage and COM-based execution, so don't get confused. But it should show you how to write a plugin with event callbacks. It is a bit more challenging, because there are threading issues involved and a separate WorkerThread is needed. But it should be clear and easy enough to get the idea.
Please post software-related questions in the forum - PMs will only be answered, if really private, thanks!
Alink
Posts: 12
Joined: Mon Dec 10, 2007 6:23 pm

Re: MediaMonkey

Post by Alink »

Oh yes, dispatch with events certainly sounds interesting! I will have a look at it.

It might take me a while to comprehend though, since I'm all new to Python. (Up until yesterday I had hardly heard of it, to be honest. But it sure is a fun learning experience so far!)

Maybe Pako has the skills and time to implement it. :wink: *winks in hope*
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: MediaMonkey

Post by Pako »

Well, I it try. But will it take a long time.
For the present is here at least version 0.1.3
Included:
- autoconnect MM
- LoadPlaylist Action
- Exit/Disconnect MM choice

Pako
Attachments
__init__.py
Version 0.1.3
(46.2 KiB) Downloaded 353 times
Alink
Posts: 12
Joined: Mon Dec 10, 2007 6:23 pm

Re: MediaMonkey

Post by Alink »

Pako wrote:Well, I it try. But will it take a long time.
For the present is here at least version 0.1.3
Included:
- autoconnect MM
- LoadPlaylist Action
- Exit/Disconnect MM choice

Pako
Great work, Pako! :)

A comment though:
Now there is an autoconnect, but no autorelease. IMO autorelease is the preferred way to go, since you never risk getting the COM warning when closing the app manually. I tried:

Code: Select all

# in plugin
    def ReleaseMM(self):
        if self.MM is Not None:
                del self.MM
                self.MM = None

# and at the end of actions
    self.plugin.ReleaseMM()
It seems to work just fine so far!
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: MediaMonkey

Post by Pako »

New beta release (0.1.5) is here.
Main changes:
1) new icon on base MM version 3
2) complement new properties (for instance Custom 4 and Custom 5, Grouping )
3) new actions:
Load Playlist by Filter
Set Continous playback
Set Shuffle tracks
Set AutoDJ
Set Crossfade
Get AutoDJ
Get Crossfade

Please test !

Pako
Attachments
__init__.py
Release 0.1.5
(91.08 KiB) Downloaded 312 times
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: MediaMonkey

Post by Pako »

Only one tiny change -> Release 0.1.6
Pako
Attachments
__init__.py
Release 0.1.6
(91.08 KiB) Downloaded 342 times
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: MediaMonkey

Post by Pako »

New beta release (0.1.7) is here.
Three new actions:
- Add current playing song to Playlist (by name)
- Remove current playing song from Playlist (by name)
- Remove current playing song from Now playing window
All three actions have option verbose or numeric result.

Request from: http://www.mediamonkey.com/forum/viewto ... aying+song

Pako
Attachments
__init__.py
Release 0.1.7
(98.81 KiB) Downloaded 340 times
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: MediaMonkey

Post by Pako »

New beta version ( 0.1.8 ) is here.

One new action:
Get basic song info of next track

Pako
Attachments
__init__.py
Version 0.1.8
(105.86 KiB) Downloaded 352 times
klaritz
Posts: 5
Joined: Thu Jul 24, 2008 8:23 pm

Re: MediaMonkey

Post by klaritz »

Hello Pako,

I made in the last few days a lot of configuration work with EventGhost and I started to control MediaMonkey. At first thank's a lot for your great work for the MediaMonkey-plugin. But I have a few problems with it.

At the beginning EventGhost could not read the MediaMonkey Plugin, the error measseg was: Can't read __init__.py for plugin "MediaMonkey".

I did some changes within your plugin (quick and dirty, just to find the problem) and there have been a few issues:
1. You used "eg.RegisterPlugin", but this does not exist in my eg-folder (I am using EventGhost version 0.3.5c build 908, fresh installed). Based on other samples I changed this to "class PluginInfo".
2. the line "from eg.WinApi.Utils import CloseHwnd" made problems: eg.WinApi.Utils exists, but there is no "CloseHwnd". I found a "CloseHandle" and used this instead, only to get the plugin started.
3. "eg.WindowMatcher" does not exist in my eg-folder, I replaced this with "eg.FindWindow.WindowMatcher".

After this changes the plugin started and a lot of functions are working fine. But some functions, for example: "Exit/Disconnect MediaMonkey" or "Volume Up" etc. are not working. The error message is always the same: AttributeError: 'EventGhost' object has no attribute 'ConfigPanel'

Could you explain the problems with MediaMnokey plugin or give me an hint what's going wrong at my system. Thank you very much in advance.

cu, klaritz
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: MediaMonkey

Post by Pako »

klaritz wrote:I am using EventGhost version 0.3.5c build 908, fresh installed
Oh, this is very old version.

Please try the latest *_Setup.exe from here:
http://www.eventghost.org/downloads/

Pako
User avatar
GBWebmaster
Experienced User
Posts: 115
Joined: Wed Sep 24, 2008 5:34 am

Re: MediaMonkey

Post by GBWebmaster »

Hello Pako,
thank you for your PlugIn, I like it, especially the makro "Load Playlist by Name".
Is there a possibility to select any album in my database and play this one? Maybe I have not found the command, but this would be great.

GBWebmaster
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: MediaMonkey

Post by Pako »

Hi GBWebmaster!
GBWebmaster wrote:Hello Pako,
thank you for your PlugIn, I like it, especially the makro "Load Playlist by Name".
:) :D
GBWebmaster wrote: Is there a possibility to select any album in my database and play this one? Maybe I have not found the command, but this would be great.GBWebmaster
Meantime you can only use the complex Action "Load Playlist by Filter." But I think about the creation of simpler actions, which could be choosen only by one criteria.
The condition could be transmitting as a payload events, so would not create a special macro for each condition (for example Album).
Pako
User avatar
GBWebmaster
Experienced User
Posts: 115
Joined: Wed Sep 24, 2008 5:34 am

Re: MediaMonkey

Post by GBWebmaster »

Pako wrote:But I think about the creation of simpler actions, which could be choosen only by one criteria.
The condition could be transmitting as a payload events, so would not create a special macro for each condition (for example Album).
Pako
Does it mean, that this makro should work like a jukebox? For example, "The Beatles White Album" gets the Number "544"? That would be really great. :D
Is it ever possible to choose one event with more than one remote press? :?:

GBWebmaster
F├╝r den, der nie das Rudel anf├╝hrt,
wird sich die Aussicht nicht ändern.
Post Reply