INTERACT FORUM

Please login or register.

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

Author Topic: Is Delay needed when calling Info after Next (MCWS)?  (Read 5371 times)

Windcrest77

  • Junior Woodchuck
  • **
  • Posts: 63
Is Delay needed when calling Info after Next (MCWS)?
« on: May 25, 2015, 05:09:34 pm »

Hi,

I'm trying my hand developing a little manual BPM program using the MCWS (REST web service).

I have a "Next" button that calls the Playback/Next method:

http://localhost:52199/MCWS/v1/Playback/Next?Zone=-1&ZoneType=ID

Then within that same  button Click even I immediately call the current Info method:

http://localhost:52199/MCWS/v1/Playback/Info?Zone=-1

So that I can populate the BPM and song title on my app form.

But what happens is the second call to Playback/Info always returns the song that was playing previously, in other words the song I'm hearing after the Next method doesnt get queried back with the Info call.

Now here's the weird part, if I make my Click even wait 500 millisends between making the Next call and doing the Info call. Everything works fine, the Next (current) song gets queried as current.

Here is a sample of the  pseudo code (all the calls to the web service are synchronous inline calls (no asynch Http GET is being done), in VB: My question is why do I need to have my Thread sleep 500 milliseconds after a Next to get the Info to return the real current song?

Pseudocode:

Begin Click event:

Call Next:

http://localhost:52199/MCWS/v1/Playback/Next?Zone=-1&ZoneType=ID

Sleep:

System.Threading.Thread.Sleep(500)

Call Info:

http://localhost:52199/MCWS/v1/Playback/Info?Zone=-1

Good results (BUT when I comment out the Sleep(500) then Info always returns the "previous" song, not the current.)

Move the data to the UI.

End Click event:

I'm OK with doing it this way but I'd rather not introduce an intentional delay when the music I'm hearing has already gone to "Next", I think the Info call at that point should return the currently playing song.

Thanks for any help
Rick




Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41866
  • Shoes gone again!
Re: Is Delay needed when calling Info after Next (MCWS)?
« Reply #1 on: May 25, 2015, 06:52:08 pm »

Next with:
http://localhost:52199/MCWS/v1/Playback/Next?Zone=-1&ZoneType=ID

Is going to delay a little before taking effect.  It just forwards the command to MC but then MC executes it in a little bit asynchronously.

I'll look at adding a Delay=1 parameter to the call, but I'm not sure if that'll be possible.
Logged
Matt Ashland, JRiver Media Center

Windcrest77

  • Junior Woodchuck
  • **
  • Posts: 63
Re: Is Delay needed when calling Info after Next (MCWS)?
« Reply #2 on: May 26, 2015, 12:14:23 am »

Thanks,

I thought I'd mention the behavior, I'm OK with using a Sleep its not a show stopper, just a quirk. The MCWS is a way better solution than DCOM or COM+ Interop from .Net. Mainly because it's more standard, a person can write a client in any language or platform they want with web services. I'm new to JRiver but like it a lot.

Rick

Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41866
  • Shoes gone again!
Re: Is Delay needed when calling Info after Next (MCWS)?
« Reply #3 on: May 26, 2015, 07:57:20 am »

Next build:
Changed: Added a "Block" parameter to the next call in the web service so that it's possible to have the return of the call wait until the next has been processed.

So this blocks:
http://localhost:52199/MCWS/v1/Playback/Next?Zone=-1&ZoneType=ID&Block=1
Logged
Matt Ashland, JRiver Media Center

Windcrest77

  • Junior Woodchuck
  • **
  • Posts: 63
Re: Is Delay needed when calling Info after Next (MCWS)?
« Reply #4 on: May 26, 2015, 11:34:34 pm »

Thanks Matt,

Not to use up my credit card, but I suspect the "Playback/Previous" REST method will also need this.

Logged

Matt

  • Administrator
  • Citizen of the Universe
  • *****
  • Posts: 41866
  • Shoes gone again!
Re: Is Delay needed when calling Info after Next (MCWS)?
« Reply #5 on: October 25, 2016, 07:35:26 am »

I'm a little slow on the response, but coming next build:
Changed: Added a Block parameter to the Previous call like there's already a Block parameter for the MCWS/v1/Playback/Next command.
Logged
Matt Ashland, JRiver Media Center
Pages: [1]   Go Up