MM Comm Objects in WCF App Locking Database for Updates

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

MyVikes
Posts: 6
Joined: Sun Jul 02, 2017 1:20 am
Contact:

MM Comm Objects in WCF App Locking Database for Updates

Post by MyVikes »

I've written a VB.Net app which uses Windows Communication Foundation (WCF) and the MediaMonkey COM objects to expose a set of RESTful web services. These services allow an Android app, which I also wrote, to interact with MediaMonkey to randomly add albums to the current playlist, get the current playlist (with album art) or song, stop/start the player, etc.

The application is a Windows Form Application which starts a backgroundworker thread that opens a WCF WebServiceHost and ServiceEndpoint for the various API endpoints (OperationContract). These endpoints return json objects which are then used to update the Android app views, etc.

Functionally all of this is working quite well except what I’m seeing is that after using the API's if I then try to update a song tag, album art, etc. in the MM library using the MM application itself the database appears to be in a locked state and the update transactions from MM are queued.

In each of my endpoints I create a SDB reference and also set it to "Nothing" at the end of the function before returning the json object. The only thing I can think of is that "scripts" begin and end whereas my applications backgroundworker is always in a listening state so the application never ends.

I’ve search the MM forum extensively for insights but have been unsuccessful in finding any clues as to what I might be doing wrong. Any help on understanding what I might be overlooking would be greatly appreciated.

Example code to ping MM to see if it is in a play or paused state:

Code: Select all

Public Interface IService
    <OperationContract()>
    <WebGet(ResponseFormat:=WebMessageFormat.Json, BodyStyle:=WebMessageBodyStyle.Bare)>
    Function [b]IsPlaying()[/b] As Boolean
…….
End Interface

Public Class Service
    Implements IService
    Public Function [b]IsPlaying[/b]() As Boolean Implements IService.IsPlaying
        Console.WriteLine("Service:IsPlaying ")

        Dim SDB = CreateObject("SongsDB.SDBApplication")

        Dim isPlayingNow As Boolean = False

        If SDB.Player.isPaused Or Not SDB.Player.isPlaying Then
            isPlayingNow = False  
        Else
            isPlayingNow = True  
        End If

        Console.WriteLine("...isPlayingNow:" & isPlayingNow)

        SDB = Nothing

        Return isPlayingNow
    End Function
…………
End Class
MyVikes
Posts: 6
Joined: Sun Jul 02, 2017 1:20 am
Contact:

Re: MM Comm Objects in WCF App Locking Database for Updates

Post by MyVikes »

After much exploration and testing scenarios I have discovered the issue is not with the code or COMM objects but rather Visual Studio. It seems when I run the application from VS I have to exit the application (not stop it from VS) to free up MM. When I run the application externally (not in VS) it works just fine. Very odd and no real explanation but that is what i have discovered. :-?
Post Reply