any .NET developers here?

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

darchangel
Posts: 26
Joined: Wed Nov 30, 2005 11:23 pm

any .NET developers here?

Post by darchangel » Wed Jun 13, 2007 7:27 am

Does anyone here code in .NET? I'm coming across some weirdness in C# and don't know if I'm finding bugs or if it's due to a deficiency in my coding. In particular, when you're calling "new SDBApplicationClass()", is there anything special you need to do with interop or should it work as is ("as is" = with just a reference to the COM and with the appropriate using statement)?

When I do this and try to subscribe to events, I'm not receiving the event notifications. Has anyone else faced this problem in .NET?

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Wed Jun 13, 2007 9:16 am

Yes, I've been in the same situation as you (and in fact I'm still in that situation). Unfortunately very few MM forum users can program .NET, or at least only very few users respond questions about it. If you search the forum, you'll probably find 2 of such requests from myself.
And yes, I think that it should work with .NET "as is".
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

darchangel
Posts: 26
Joined: Wed Nov 30, 2005 11:23 pm

Post by darchangel » Wed Jun 13, 2007 6:14 pm

Ouch! I spent some time looking through this forum via google (thank you microsoft for making sure ".net" and "c#" are impossible for any but the most advanced search engines to distinguish.) You've posted a depressing number of posts about all of the problems I've had. You also seem to have tried everything I have plus a few options and had the same results ::sigh::

I suppose I should be encouraged that I'm not the only one with these problems and that it doesn't seem like I've done anything wrong.

Here's one to add to our list of ideas that don't work: if you use a script to auto launch a .net app and use that to launch a winform in it's own thread, then wacky things occur when you try to use methods controlling the player.

nduke
Posts: 55
Joined: Sat Jul 09, 2005 7:29 am
Location: Marietta, GA

Post by nduke » Wed Jun 13, 2007 8:22 pm

I've come across some of the same frustrations. I've never been very successful at controlling the player from C#.

I've ended up using my C# apps just for things like building advanced playlists of different kinds of syncing. Other than extracting info from MM, the .Net apps are flaky.

Also, you are ABSOLUTELY right about how annoying it is to search for anything C# or .Net related! Thank god Google can handle the 'C#' searches!

Peke
Posts: 12472
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Wed Jun 13, 2007 10:53 pm

OK May I suggest small thing?
Have you tried to control Winamp from C#? If yes Use same for MM and all should work. Except where is winamp.exe replace with mediamonkey.exe.
Best regards,
Pavle
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Thu Jun 14, 2007 6:27 am

Using something like this

Code: Select all

SongsDB.SDBApplicationClass SDB = new SongsDB.SDBApplicationClass();
SDB.ShutdownAfterDisconnect = false;

SDB.Player.Next
works fine for me. The biggest issues I have is that I can't attach to events in MM (at least, I'm not notified of events) and the "connection" to MM isn't always stable (COM errors, and in extreme cases slow or no MM response)

BTW: As you notice I'm using MediaMonkey's COM/Scripting interface, not the API Messages. The interface is much more powerful and ".NET-able".
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Peke
Posts: 12472
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Thu Jun 14, 2007 10:00 am

When I make third party app I use both COM and PostMessage (Win API) to ensure that all is OK also like you said COM connect can slow down a little.
Best regards,
Pavle
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Thu Jun 14, 2007 10:13 am

SongData sub-objects don't seem to work through COM in MM2, e.g.
..SDB.Player.CurrentSong.Artist
..SDB.Player.CurrentSong.Album
..SDB.Player.CurrentSong.AlbumArt
.....
are always null.

However, in MM3 this all works fine and is certainly good news. Maybe other things will work well in MM3 too.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Peke
Posts: 12472
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Thu Jun 14, 2007 12:11 pm

@Steegy
Above mentioned fields should be null (except maybe album art) if file is not in library but if it is in library I have no problems with them.
Best regards,
Pavle
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Thu Jun 14, 2007 4:55 pm

They're all null for me, when using C#.Net with songs that are in my database and have album, artist and albumart.
Using scripting, there is no problem.

Unfortunately MM doesn't log COM interaction, and if it does, it's clearly that MM2 (for me) doesn't query the Album, Artist and AlbumArt objects for C#.Net.
I do see logging (GetFileInfo, DB open SQL, ...) when using VBScript.

But, the most important thing is that it works in MM3 so in the future it should be fine.

I'm using a small rudimentary screensaver app to test it atm: http://home.scarlet.be/ruben.castelein/Screensaver.zip (C#.Net2)
I'm currently 'looking' to get Winamp visualizations in the background.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Peke
Posts: 12472
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Thu Jun 14, 2007 8:54 pm

:) I must say that ScreenSaver do not work on my PC "No mediaMonkey Started" :)

Just Testing In Delphi by creating Third party exe and all I used is:

Code: Select all

unit COMtest;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Controls, Forms,
  StdCtrls, ComObj;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  SDB: OleVariant;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  SDB := CreateOleObject('SongsDB.SDBApplication');
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  Memo1.Lines.Append('Title: '+SDB.Player.CurrentSong.Title);
  Memo1.Lines.Append('Artist: '+SDB.Player.CurrentSong.ArtistName);
  Memo1.Lines.Albumname('Artist: '+SDB.Player.CurrentSong.ArtistName);
end;

end.
And All is OK
Hmmm... I'll investigate Events later, Jiri have changed things there for better compatibility.
Best regards,
Pavle
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Thu Jun 14, 2007 11:05 pm

I must say that ScreenSaver do not work on my PC "No mediaMonkey Started"
That's probably because your MediaMonkey program file isn't named MediaMonkey.exe or MediaMonkey_debug.exe. A code change was planned for that, but I didn't think it would be needed so soon :)

Code: Select all

begin 
  Memo1.Lines.Append('Title: '+SDB.Player.CurrentSong.Title); 
  Memo1.Lines.Append('Artist: '+SDB.Player.CurrentSong.ArtistName); 
  Memo1.Lines.Albumname('Artist: '+SDB.Player.CurrentSong.ArtistName); 
end;
Well, you don't test the Album, Artist or AlbumArt objects here. Title, AlbumName and ArtistName work just fine here too.
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Peke
Posts: 12472
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Fri Jun 15, 2007 2:53 pm

Steegy wrote:....but I didn't think it would be needed so soon
:) Why do you search For MediaMonkey.exe search for Window name Contain MediaMonkey and TMainForm.

Code: Select all

  Memo1.Lines.Append('Title: '+SDB.Player.CurrentSong.Title);
  Memo1.Lines.Append('Artist: '+SDB.Player.CurrentSong.Artist.Name);
  Memo1.Lines.Append('Album: '+SDB.Player.CurrentSong.Album.Name);
  Memo1.Lines.Append('Track: '+IntToStr(SDB.Player.CurrentSong.TrackOrder)+'/'+IntToStr(SDB.Player.CurrentSong.Album.Tracks.Count));
  Memo1.Lines.Append('Covers: '+IntToStr(SDB.Player.CurrentSong.AlbumArt.Count));
This one do test all that and for example result look like this
  • Title: Baci che si rubano
    Artist: Laura Pausini
    Album: Laura Pausini
    Track: 4/8
    Covers: 1
Best regards,
Pavle
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum

Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm
Location: Belgium
Contact:

Post by Steegy » Fri Jun 15, 2007 5:27 pm

Why do you search For MediaMonkey.exe search for Window name Contain MediaMonkey and TMainForm.
I normally do that, using the API: FindWindow.
However, now I wanted to try to use only C# code (no P/Invoke, Interop, API, ... you name it). .NET's way is to give you (only) access to the running processes. It doesn't support searching for windows.

BTW: I'm using MM 2.5.5.988 (and no, I'm not updating to the lastest one :))
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).

Peke
Posts: 12472
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Post by Peke » Fri Jun 15, 2007 5:53 pm

Steegy wrote:BTW: I'm using MM 2.5.5.988 (and no, I'm not updating to the lastest one :))
I've used that version too MediaMonkey.exe Filesize 4,697,600 Bytes.
Best regards,
Pavle
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum

Post Reply