INTERACT FORUM

More => Old Versions => Media Jukebox => Topic started by: Scronch on August 20, 2002, 02:02:31 am

Title: Command Line timing problem
Post by: Scronch on August 20, 2002, 02:02:31 am
I can't get the timing to work on issuing some command line commands.  I want to clear Playing Now, raise the volume, play a short file (via a playlist name), lower the volume, and then append a playlist.  Two problems: The volume goes up and down before the first Play command is carried out, and the second playlist overrides the first.  Here is what I've tried:


@echo off
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Mode Megame
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Clear
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 100
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Play "TREEPATH=Playlists\Mixes\One Song Playlist"
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 80
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Append "TREEPATH=Playlists\Main Playlist"


I even tried putting a pause in between commands, but the pause gets executed (i.e. I hear silence) before any of the commands are carried out:


@echo off
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Mode Megame
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Clear
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 100
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Play "TREEPATH=Playlists\Mixes\One Song Playlist"
echo Waiting 2 second(s)...
echo Do                      >%TEMP%.\~tmp.vbs
echo Loop Until True = False>>%TEMP%.\~tmp.vbs
CSCRIPT //B //Nologo //T:2 %TEMP%.\~tmp.vbs
del %TEMP%.\~tmp.vbs
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 80
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Append "TREEPATH=Playlists\Main Playlist"


How can I get this to work?  Specifically, how can I get the volume to go up for one song, play that song, and THEN lower the volume back down--without trying to schedule a task time based on the length of the song?  And how can I get the Append command to wait for the other commands to complete before smashing in on everything?

Scronch
Title: RE:Command Line timing problem
Post by: KingSparta on August 20, 2002, 04:33:10 am
Not to want to rain on your parade, but could you explain to me what your doing all this for?

is there a reason for runing this from a batch file?

maybe I am missing something here, But I'm just trying to finger out what all this batch file stuf is for.
Title: RE:Command Line timing problem
Post by: Scronch on August 20, 2002, 01:14:19 pm
Because the whole thing is run by scheduled tasks, which call batch files, which call other batch files or issue MJ commands.  Works great, except for a few glitches like these.

Scronch
Title: RE:Command Line timing problem
Post by: KingSparta on August 20, 2002, 01:16:09 pm
I See
Title: RE:Command Line timing problem
Post by: RemyJ on August 20, 2002, 07:54:11 pm
Sounds like mjextman needs a /WaitForCommandToComplete option otherwise it just queues the command to the main application and returns.
Title: RE:Command Line timing problem
Post by: Scronch on August 20, 2002, 09:44:50 pm
I agree, but I think it's a little more complicated than that.  In the code above, when the "/Play" command is issued, it completes and the song starts playing.  But I don't want the "VolumeSet 80" to kick in until that one song has ended.  Not sure how to do that.

However, a /WaitForCommandToComplete option should fix the problem of the Append effectively cancelling the prior Play.

QUESTION: Why wouldn't you always want to wait for the previous command to complete?  I suppose some commands can be safely issued in parallel, but many of the MJ commands are sequential by their very nature.

Scronch
Title: RE:Command Line timing problem
Post by: RemyJ on August 20, 2002, 10:22:36 pm
Someone on the development will have to jump in with the real answer of course, but I think they ARE being executed sequentially.  mjextman puts a command on a queue and returns.  MJ is monitoring the queue and executes the commands in the order they were placed on the queue.  Some commands are "executed" differently than others. Setting modes and volumes are simple short-lived actions.  Playing a track is not.  The thread that picks up messages from the queue can't wait for the track to finish playing before it picks up the next command so it has to dispatch the command off to something else and keep reading the queue.

Even though I suggested the /WaitFor... option, as I think about it I'm not sure it will be either easy or even possible to implement.   If you play a playlist for instance and use the theoretical /WaitFor... option, what happens if someone manually re-arranges, inserts, or deletes tracks from Playing Now?

All of this is just speculation of course based on how I've written stuff like this in the past.
Title: RE:Command Line timing problem
Post by: Scronch on August 21, 2002, 12:36:19 am
Assuming your conjecture is accurate, I think the problem with /Append smashing the previous /Play shows that MJ may not be reading the command queue quickly enough (?).

Scronch
Title: RE:Command Line timing problem
Post by: Scronch on August 25, 2002, 09:34:22 pm
...waiting patiently for JRiver response...
Title: RE:Command Line timing problem
Post by: Scronch on August 26, 2002, 08:55:20 pm
Title: RE:Command Line timing problem
Post by: Beerhunter on August 28, 2002, 11:29:18 pm
Totally ignored, again, dude.  Really rad.
Title: RE:Command Line timing problem
Post by: JimH on August 29, 2002, 06:45:58 am
Scronch,
We're busy.  This is way way down the list in priority.

If you bring it up again in a few weeks, we MIGHT take a look.

Jim
Title: RE:Command Line timing problem
Post by: Nikolay on August 29, 2002, 08:52:34 am
Scronch,

There is no easy way to do what you've described. /Play command is asynchronous. It will return immediately after a song has been added to the playlist.

One of the ways to do what you want is to write an Interface plug-in which will schedule the tasks.

Nikolay
Title: RE:Command Line timing problem
Post by: Cephlen on August 29, 2002, 10:22:54 am
Yeah, write an interface plugin!

You would have so much more flexibility...

If you explain to me a bit more what you are trying to accomplish, I can help you out... if there is a need for something flexible like this, maybe I can write one for everyone.
Title: RE:Command Line timing problem
Post by: Scronch on September 02, 2002, 09:14:57 pm
JimH - Makes sense to me.  I just like to hear that it's way way down the list, rather than wondering.

Nikolay - OK, guess I'm out of luck on setting the volume for one song.  I'm still not sure why the later /Append command completely overrides the earlier /Play command.  I would think that the song called out by the /Play command would be put in PN, and then the songs called out by the /Append command would be appended below that.  But what happens is that the /Play song never shows up in the list.  Something strange is going on with the timing of the commands.

Cephlen - I'm trying to clear Playing Now, raise the volume, play a short file (via a playlist name), lower the volume, and then append a playlist.  This is done in a batch file, which is executed as a scheduled task.

Thanks.

Scronch