OK, i really need some help from the remoting buffs in here. (1 Viewer)

MrSensitive

Portal Pro
May 18, 2004
239
0
Belgium
please take a look at the following code snippet..
Code:
public int PlayAlbum(int AlbumID)
		{
			//Get all tracks from the album and initialize the playlistplayer?
			PlayListPlayer.GetPlaylist(PlayListPlayer.PlayListType.PLAYLIST_MUSIC).Clear();
			PlayListPlayer.CurrentPlaylist = PlayListPlayer.PlayListType.PLAYLIST_MUSIC;
			PlayList.PlayListItem playlistItem = new PlayList.PlayListItem();
		
			playlistItem.Type = PlayList.PlayListItem.PlayListItemType.Audio;
			playlistItem.FileName = @"M:\my Albums\Bjork - Homogenic\04 Bachelorette.mp3";
			playlistItem.Description = "testing, testin 123";
			playlistItem.Duration = 23;
			PlayListPlayer.GetPlaylist(PlayListPlayer.PlayListType.PLAYLIST_MUSIC).Add(playlistItem);

			PlayListPlayer.Play(0);
			return 1;
		}
this method is exposed in a remoting interface, but somehow it keeps failing.

it probably has to to with the fact that a singleton is being called (PlayListPlayer).

when I execute the method within the assembly itself, everithing works fine.
when I try to execute it using remoting, strange things happen.
sometimes it just works, most f the times a Syste.remoting exception occurs and sometimes the song plays, but it seems that it is running not in the Mediaportal context..

some programmers at work said somethng about PlaylistPlayer not being threadsafe.. but that is not really my cup of tea..

many thanks in advance.

(BTW, as soon as I get this stable, We can release a first version of MPBlue 8) )
 

MrSensitive

Portal Pro
May 18, 2004
239
0
Belgium
anyone?

surely there must be real geniuses in here?

i did some more testing, and it has to do with the fact that, when using remoting, another thread is used, i could not test this, but msdn has a few articles on this..
http://msdn.microsoft.com/newsgroup...-DC48AB0DA5C9&dglist=&ptlist=&exp=&sloc=en-us
has some similar issues..
'look for the post titled Singleton like pattern implementation...

I really need to find a way to get this to work...also, i'm pretty sure that in this manner I can create a second instance of the singleton..

BT, if You want to look at the full source, it is in sourceforge.. prjectname is MPBlue..

any help is greatly appreciated..
 

talos

Portal Pro
August 24, 2004
53
0
UK
One thing to look out for is that remoted singleton objects on the server have a lease time. Because the garbage collector will collect any objects without a reference, you obviously don't want this to happen for a remote object, so the GC will hold off on a MarshalByRefObject until its inital lease time runs out (default is 5 mins) or 2 mins after the last reference. You can change this by overriding the InitializeLifetimeService (google this for more info) on the MarshalByRef object.
As I say, I'm not sure this is your problem, but it's worth looking into especially if you have problems occurring whilst debugging (which can easily eat up a couple of minutes).
 

MrSensitive

Portal Pro
May 18, 2004
239
0
Belgium
hmm, a bit over my head...

the funny thing is that while debugging, it always worked.. :?

anyway, i have found another solution, so this thread is not necessary anymore..

but thanks for your feedback..
 

Users who are viewing this thread

Top Bottom