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

Posts: 3
Joined: Sun Jul 02, 2017 1:20 am

MM Comm Objects in WCF App Locking Database for Updates

Post by MyVikes » Sun Feb 09, 2020 12:19 pm

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
    <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  
            isPlayingNow = True  
        End If

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

        SDB = Nothing

        Return isPlayingNow
    End Function
End Class