INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: New to developing but know JRiver MC and Visual Basic  (Read 3531 times)

Chriswires

  • Recent member
  • *
  • Posts: 8
New to developing but know JRiver MC and Visual Basic
« on: May 30, 2023, 02:32:34 am »

Hi,

I have a lot experience with Media Centre and writing Visual Basic and VBA and want to put these together to have some fun. Having trouble getting started

I would like to be able to loop though a playlist and perform some actions each time there is a new track (such as reading and writing to track fields and setting MC volume or altering DSP parameters).

I have looked at various help on this but seems out of date.

Installed the media centre scripting for Media Centre 12 into Windows but it did not appear as expected under MC Services. Also, I have MS Visual Studio 2022. But cannot seem to link it up with Media Centre or know the key commands to get started.

Any example programs or scripts would be great.

Any help would be gratefully received.

Logged

JimH

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 72531
  • Where did I put my teeth?
Re: New to developing but know JRiver MC and Visual Basic
« Reply #1 on: May 30, 2023, 03:00:06 am »

Try using MCWS.  On the Developer page.
Logged

Chriswires

  • Recent member
  • *
  • Posts: 8
Re: New to developing but know JRiver MC and Visual Basic
« Reply #2 on: May 30, 2023, 04:26:00 am »

Hi,  Many thanks for your prompt response  :)

I have now looked at that and it seems to have a good deal of the functionality I am looking for e.g. Loop through tracks in a playlist, load DSP presets and display info etc.

Two further questions:

1.
I am using a windows batch file and calling up the commands using the start "" approach e.g

REM play
start "" http://localhost:52199/MCWS/v1/Playback/Play?Zone=-1&ZoneType=ID

This would make it difficult to read data and set variables, it there a better way of structuring the program?

2. How would you read a specific field of the current track (such as 'Volume Level (R128)')?

Again any assistance would be great

Logged

eve

  • Citizen of the Universe
  • *****
  • Posts: 689
Re: New to developing but know JRiver MC and Visual Basic
« Reply #3 on: May 30, 2023, 01:10:19 pm »

Hi,  Many thanks for your prompt response  :)

I have now looked at that and it seems to have a good deal of the functionality I am looking for e.g. Loop through tracks in a playlist, load DSP presets and display info etc.

Two further questions:

1.
I am using a windows batch file and calling up the commands using the start "" approach e.g

REM play
start "" http://localhost:52199/MCWS/v1/Playback/Play?Zone=-1&ZoneType=ID

This would make it difficult to read data and set variables, it there a better way of structuring the program?

2. How would you read a specific field of the current track (such as 'Volume Level (R128)')?

Again any assistance would be great

I sometimes use bat files to call these things (autohotkey can be a little more flexible, especially if there's other automation you need to do in terms of setting window visibility or moving things around).
 Try asking ChatGPT (seriously). If you know a tiny bit of programming it's extremely useful at coming up with solutions to simple tasks like this or quickly writing boilerplate code.

As for reading a specific field, using MCWS? I use 'Current'

/mcws/v1/Files/Current?Action=json&ActiveFile=-1&Formatted=1&Zone=-1&ZoneType=ID

I find json data the easiest to work with in the software I tend to use. You can change formatted to 0 if you have your own method for formatting. You can also target a specific zone, or use -1 to use the currently active zone.
This *should* return any metadata associated with an item. You can then go 'get' the field you're interested in.

Most of my jriver automation gets wired up in node red. Since I sometimes have to manually automate the computer running JRiver itself, occasionally this is accomplished by calling autohotkey / powershell scripts on that system. For those, I run a tiny rest server that lets me trigger the scripts / functions with simple http requests.

Logged

Chriswires

  • Recent member
  • *
  • Posts: 8
Re: New to developing but know JRiver MC and Visual Basic
« Reply #4 on: June 01, 2023, 02:43:46 pm »

Eve:

Thanks for your advice.
These commands do achieve many of the things I am looking for including:

- Give total number of tracks in playlist and current position.
- Play / pause / play specified track in playlist e.g. track 51 of 122.
- Get track info such as volume (thanks for showing me the command to do this).
- Set DSP to adjust volume.

So can program to loop through each track, read track volume and adjust system volume via DSP to achieve my desired volume levelling.  (I currently use track-specific DSP settings but they are loaded about 5 seconds before the end of previous track which is really annoying). Anyway I would like to learn how to automate Media Center.

The problem remains of how to detect that a new track has been loaded which would trigger the routine to check and adjust volume - any ideas?

Cheers
Logged

Chriswires

  • Recent member
  • *
  • Posts: 8
Re: New to developing but know JRiver MC and Visual Basic
« Reply #5 on: June 15, 2023, 03:09:06 am »

Hi all,

Many thanks to eve - the following MCWS command to retrieve info about current track being played is exactly what I need.

http://localhost:52199/MCWS/v1/Files/Current?

I have managed to make quite a bit of progress with my project - but now looking for further help.

I have tried C++. See below, could 'send' commands to control media server but could not find a way to 'read' information from it.

Swapped to Python and had more success.  I have used the pymcws module written by Keno Maerz which does a great job of interfacing the MCWS commands to a Python script.

Here is my working Python script:

# first load up the relevant modules #
import pymcws as mcws
import json

#connect to JRiver Media Center#
office = mcws.get_media_server_light("stHpKr", "readonly", "supersecretpassword")

#send one of the MCWS commands - in this case it gets info on the currently playing track#
Myfile=mcws.playback.info(office)

#this line converts the retrieved info into a string format that can be printed#
y=json.loads(json.dumps(Myfile))

# print currently playing track:
print("Now playing ...")
print("Artist: " + y["Artist"])
print("Name: " + y["Name"])
print("Album: " + y["Album"])


Running this gives the following successful output

Now playing ...
Artist: Town Called Malice
Name: The Jam
Album: Our Generation

The question I have is how would I bring back a field not in the 'playback.info' list?
For example – ‘Volume Level (R128)’?

Turning to my issue with C++ coding, here is the relevant extract:

This MCWS command sent via a web browser gives lots more info about current track being played, including ‘Volume Level (R128)’ (The response is in a .mpl file).
http://localhost:52199/MCWS/v1/Files/Current?

//make a string variable to hold the URL to send//
string Myurl = "explorer http://localhost:52199/MCWS/v1/Files/Current?";

//send the command to Media Center and capture response in a suitable variable Myxml//   
auto Myxml = std::system(Myurl.data());

//try and print the response//
std::cout << "Myxml = ";
std::cout << Myxml;

Running this gives the following output:

Myxml = 1

This is not what I require.  I would like to receive the whole response so I can extract the data from ‘Volume Level (R128)’.

Any help would be really great.

Chris

 :D

Logged

Chriswires

  • Recent member
  • *
  • Posts: 8
Logged
Pages: [1]   Go Up