INTERACT FORUM

Please login or register.

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

Author Topic: Windows Command Script  (Read 2358 times)

Scronch

  • Guest
Windows Command Script
« on: July 08, 2002, 09:29:49 pm »

I'm still more used to Unix than Windows, so maybe somebody can help me out with this.  I'd like to write a little Windows script to start MJ with a playlist based on the time of day.  It will be very short, so I prefer an interpretive shell script, I think.  I want it to look something like this:

if 0<=[hour of time of day]<=12
  then do
    C:\Program Files\J River\Media Jukebox mjextman.exe /Play "TREEPATH=Playlists\MorningList"
  end do

if 12<[hour of time of day]<=17
  then do
    C:\Program Files\J River\Media Jukebox mjextman.exe /Play "TREEPATH=Playlists\AfternoonList"
  end do


And so on.  I realize that a DOS script won't look this structured, but that's OK.  What I need is the call to get hour of day and the if-then structure that would work.  If you'd recommend something other than a script, short of compiling something, let me know.  Thanks for your help.

Scronch
Logged

claudio

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 265
RE:Windows Command Script
« Reply #1 on: July 08, 2002, 09:42:01 pm »

Hey Scronch,

Why don't you use the MediaScheduler that comes with MJ?
It's a breeze to get those two command issued daily at specific times

I do something similar (startup and stop MJ at specific times)

Claudio
Logged

Scronch

  • Guest
RE:Windows Command Script
« Reply #2 on: July 08, 2002, 10:45:13 pm »

Claudio -

Pls read http://www.musicex.com/cgi-bin/interact/NeoBoard.pl?Action=ShowPost&Board=inter&Post=11668&BoardIdle=7&SortingBy=0&BoardOrder=Descend&Page=5&UserSession= and then http://www.musicex.com/cgi-bin/interact/NeoBoard.pl?Action=ShowPost&Board=inter&Post=11533&BoardIdle=7&SortingBy=0&BoardOrder=Descend&Page=0&UserSession= .  I'm trying to accomplish some specific things with Media Scheduler.  But, in addition, I want to be able to have playlists loaded based on the time of day whenever MJ is started up.

Scronch
Logged

Scronch

  • Guest
RE:Windows Command Script
« Reply #3 on: July 09, 2002, 01:09:45 am »

OK, I appear to have this working.  If there is a much easier way, please let me know.  First, I set up a separate batch file for each time-of-day playlist I have.  For example, the file mj-3-nite.bat contains:

@echo off
echo Starting Media Jukebox with Night playlist
cd C:\Program Files\J River\Media Jukebox
mjextman.exe /Play "TREEPATH=Playlists\3 - Night (7-10pm)"


Then, I call the appropriate batch file from within the main batch file based on the hour of day.  This was made a lot easier due to Windows 2000 (and I assume NT and XP) providing the %time% environmental variable:

@echo off
for /f "tokens=1-4 delims=:., " %%a in ('echo %time%') do (set hour=%%a)
echo Hour is %hour%

if 3 leq %hour% if %hour% leq 15 mj-1-aft
if 16 leq %hour% if %hour% leq 18 mj-2-eve
if 19 leq %hour% if %hour% leq 21 mj-3-nite
if 22 leq %hour% if %hour% leq 23 mj-4-late
if 0 leq %hour% if %hour% leq 2 mj-4-late

set hour=


I honestly don't see a simpler way to do this (have MJ preload and play a playlist based on the time of day it is started--this is NOT the same as using Media Scheduler).

This solves one problem, but doesn't help with my quest to have MJ automatically change Smartlists at specified times of day (two links above).

Scronch
Logged

zigguratt

  • Regular Member
  • World Citizen
  • ***
  • Posts: 114
RE:Windows Command Script
« Reply #4 on: July 09, 2002, 04:03:07 am »

Depending on the version of Windows you're using you could use the "at" command to set up a scheduled task. You could also simply use the Windows Task Scheduler. In addition there are good (free) versions of cron for Windows if you're more comfortable with Unix.
Logged
The latest version of Glissando can be had here.

claudio

  • Regular Member
  • Galactic Citizen
  • ****
  • Posts: 265
RE:Windows Command Script
« Reply #5 on: July 09, 2002, 05:41:38 am »

Hi Scronch,

Ohhh I see, I thought you had MJ running all the time (like me  ) and you just wanted to switch playlist at specific times..


All the schedulers (MJ scheduler, at, cron etc) won't help you. Your scripting solution seems perfectly ok.

Since this does not seems to be a scheme based on automatistm (i.e. you start the player manually at some random time of the day) I would have personally just started MJ and then manually selected the playlist of my preferece for that time of the day (1 click) , and then let the scheduler change it when next time slot come.... but that's me

Thanks for sharing this
Claudio
Logged

Scronch

  • Guest
RE:Windows Command Script
« Reply #6 on: July 09, 2002, 12:31:49 pm »

I'm really trying to do 2 things:

1) Use a script (as above) to accompish this: When somebody who doesn't know the first thing about MJ starts it up, it is preloaded with a playlist (from a smartlist) based on the time of day.

2) While MJ is playing, at certain times of the day, clear PN (without cutting off the song), and load it up with a different playlist (from a smartlist).

Scronch
Logged

Scronch

  • Guest
RE:Windows Command Script
« Reply #7 on: July 10, 2002, 10:23:14 am »

I've been playing with the script, and I appear to have item (1) above taken care of.  I can't make progress on item (2) without a little more power in the available commands.

Scronch
Logged

Scronch

  • Guest
RE:Windows Command Script
« Reply #8 on: July 11, 2002, 07:04:45 pm »

Is there another way to clear Playing Now besides right-clicking on Playing Now?  I thought if I found another path to this command, I may be able to access it through mjextman.exe.  It would be a start.  The mjextman.exe commands I use now (with Media Scheduler) sort of do this--they clear Playing Now, but they do a hard-stop on the song that's playing.

Scronch
Logged

Scronch

  • Guest
RE:Windows Command Script
« Reply #9 on: July 14, 2002, 11:19:43 am »

bump for james bailey
Logged

Ingo

  • Guest
RE:Windows Command Script
« Reply #10 on: July 14, 2002, 12:24:12 pm »

hm... did you try to play a file that can't be played? I think that clears playing now.

Ingo
Logged

Scronch

  • Guest
RE:Windows Command Script
« Reply #11 on: July 14, 2002, 01:53:42 pm »

That was a pretty good idea, but it presents a different problem.  Here is what I tried:

cd C:\Program Files\J River\Media Jukebox
mjextman.exe /Play Default\Plus.gif

Because I have Settings, Options, Playback, Stop set to Fadeout (normal), this does a nice job of fading out the currently-playing song, which is really nice.

But it pops up a Warning window that says "Please select file(s) to play", and has an "OK" button on it.  Until I click the OK button, controlling MJ is locked out.  Not sure how to emulate hitting Enter or clicking OK using mjextman.exe.

I think the best solution would be if JRiver could provide the following, as stated in the 'Command Line Switches' post:

1) An mjextman.exe /Clear Playing Now except for Current Song command (or at least honor Stop-Fadeout and then clear Playing Now).

2) An mjextman.exe /Append "TREEPATH... command that appends the playlist (or smartlist) to Playing Now without stopping the current song, and with those files being shuffled enroute to PN if shuffle is on (see the '"Playing Now > Add to end" shuffles Playing Now?' post).

Thanks for your input.

Scronch
Logged

Scronch

  • Guest
RE:Windows Command Script
« Reply #12 on: July 14, 2002, 02:15:18 pm »

Just had a thought, but before I set up trying it, I'm just wondering if Nikolay and the other JRiver folks will be adding any of the requested mjextman commands.

My thought is to use mjextman to play a song that has, say, 30 seconds of silence, and then to immediately issue the mjextman command to load up the next Smartlist.  Supposedly playing the blank song would do a Fadeout-Stop on the currently playing song, then clear Playing Now, and then play the blank song.  And then the next command would hard-stop the blank song (which is OK), and then load up the next Smartlist.

My concern is that I need to keep "Do not play extended portions of silence" turned on, for reasons unrelated to this thread.  So that might mess up playing a blank song.

Nikolay, Matt, or anyone else: should I try this, or do you think we'll get more mjextman power soon?

Thanks.

Scronch

P.S. - I have a bit more information to share.  When using the mjextman.exe /Play command, if declare a filename like c:\My Music\Alice Cooper\Greatest Hits\Elected.mp3, or if I use TREEPATH to drill through Playlists into a certain playlist or smartlist, then the currently playing song gets a hard stop.  But if I use mjextman.exe /Play to play an unplayable song, like Default\Plus.gif, then the currently playing song gets a fadeout stop.  I don't understand why they act differently.  What I'd like to accomplish is to clear PN except for the currently playing song, and append a shuffled smartlist.  If I can't do that, then I'd at least like to fadeout stop the currently playing song, and then I could use the /Play option to load up the new shuffled smartlist.
Logged
Pages: [1]   Go Up