NowPlaying.vbs / NowPlayingConf.vbs (Updated 01/23/2006)

Download and get help for different MediaMonkey for Windows 4 Addons.

Moderators: Peke, Gurus

margu
Posts: 53
Joined: Thu Feb 03, 2005 3:43 am
Location: Rheinberg, Germany

NowPlaying.vbs / NowPlayingConf.vbs (Updated 01/23/2006)

Post by margu »

Hello,

I've the above problem and am not able to find a solution, because I'm not a programmer.

I wrote a script for my needs to have a textfile with several info about the now playing song written. It uses a loop because I wanted to have the players state (stop or pause) in the textfile either.
But while it runs I neither can use my remote nor any hotkeys.

I will be very happy if someone of you script-gods can help me :-)

Code: Select all

New Code below
Last edited by margu on Mon Jan 23, 2006 1:05 pm, edited 10 times in total.
onkel_enno
Posts: 2153
Joined: Fri Jan 14, 2005 1:45 am
Location: Germany
Contact:

Post by onkel_enno »

I think each time the second script is started, mm becomes inactive and so no hotkey will work.
margu
Posts: 53
Joined: Thu Feb 03, 2005 3:43 am
Location: Rheinberg, Germany

Post by margu »

onkel_enno wrote:I think each time the second script is started, mm becomes inactive and so no hotkey will work.
Yeah, maybe. I noticed another thing now: while playing a song and I use "Next" or "Prev" at the player, the selected track in playlist don't change until i do a click on the window or do a manual refresh.
If the song is played until the end and MM switch to the next song all is ok. I think this is because the main script restarts then. Darn :-(
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Surely this line is a typo:
margu wrote:

Code: Select all

Rating = oRating & " of 5 stars"
You have not defined oRating. Using the following line at the top of your script will highlight these problems:

Code: Select all

Option Explicit
The problem you are having with your hotkeys is to do with focus. MM needs to be focused for them to work.

ADDITION: Your .ini entry has [InlineLyrics] as the key, you should change this to your [NowPlaying] :)
Last edited by trixmoto on Mon Dec 12, 2005 4:37 am, edited 2 times in total.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

margu wrote:

Code: Select all

If isPause = TRUE Then
   Status = " (paused)"
   x = 1
ElseIf isPause = FALSE And isPlay = FALSE Then
   Status = " (stopped)"
   x = 0
ElseIf isPlay = TRUE Then
   x = 1
End If 
What you have written works, but it could be streamlined thus:

Code: Select all

x = 1
If isPlay = False Then 
   Status = " (stopped)"
   x = 0
ElseIf isPause Then
  Status = " (paused)"
End If
(This works because isPlay is true when the player is paused as well)

Looks like you're doing a pretty good job considering you're...
margu wrote:not a programmer
:)
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
margu
Posts: 53
Joined: Thu Feb 03, 2005 3:43 am
Location: Rheinberg, Germany

Post by margu »

trixmoto wrote:Surely this line is a typo:

Code: Select all

Rating = oRating & " of 5 stars"
You have not defined oRating. Using the following line at the top of your script will highlight these problems:

Code: Select all

Option Explicit
Thanks, this is only in my working copy and not in my script I use :-)
I changed this.
trixmoto wrote:The problem you are having with your hotkeys is to do with focus. MM needs to be focused for them to work.
And there isn't any posibility to work around it?
After some more testing I ran into much more problems. Any other scipts work neither :-?
trixmoto wrote:ADDITION: Your .ini entry has [InlineLyrics] as the key, you should change this to your [NowPlaying] :)
Like above. Only the description has this "typo".
As you can see I took a deep look into your script and got some hints for doing my script :-)
margu
Posts: 53
Joined: Thu Feb 03, 2005 3:43 am
Location: Rheinberg, Germany

Post by margu »

trixmoto wrote: What you have written works, but it could be streamlined thus:

Code: Select all

x = 1
If isPlay = False Then 
   Status = " (stopped)"
   x = 0
ElseIf isPause Then
  Status = " (paused)"
End If
(This works because isPlay is true when the player is paused as well)

Looks like you're doing a pretty good job considering you're...
margu wrote:not a programmer
:)
Oh, this is fine, thanks.

Well "not a programmer" isn't really correct, because I did much more work on Perl but nothing in VBS before, so maybe my understanding is a bit skilled :-)
Steegy
Posts: 3452
Joined: Sat Nov 05, 2005 7:17 pm

Post by Steegy »

If the problem is a "focus" thing, can't you change the behaviour then by using other parameters for the WShell.Run method?

See http://msdn.microsoft.com/library/defau ... mthrun.asp
for intWindowStyle:
The active window remains active.
Cheers
Steegy
Extensions: ExternalTools, ExtractFields, SongPreviewer, LinkedTracks, CleanImport, and some other scripts (Need Help with Addons > List of All Scripts).
margu
Posts: 53
Joined: Thu Feb 03, 2005 3:43 am
Location: Rheinberg, Germany

Post by margu »

Steegy wrote:If the problem is a "focus" thing, can't you change the behaviour then by using other parameters for the WShell.Run method?

See http://msdn.microsoft.com/library/defau ... mthrun.asp
for intWindowStyle:
The active window remains active.
Cheers
Steegy
Woohoo :lol:
You made my day! I played a while with the parameters and now it works with following line

Code: Select all

    res = WShell.Run(command, 8, 0)
I either tried with 7 instead of 8 but this didn't work.

Thank you alot Steegy, you are 8) :-)

So, and now for all people who are interested, the fixed and cleand up code again:

Code: Select all

New Code below
If there is something going wrong: ask me :-)

..::Margu::..
Last edited by margu on Tue Dec 13, 2005 5:59 am, edited 1 time in total.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

I did recognise some of my code (before the InlineLyrics bit which definitely gave it away!) - it's no problem, that's how we learn! :)

The script looks good. I believe you can now officially call yourself a VBScript programmer! :D
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
margu
Posts: 53
Joined: Thu Feb 03, 2005 3:43 am
Location: Rheinberg, Germany

NowPlaying Script (Update)

Post by margu »

Hello,

above started and with perfect help fixed, I wanted to release my script and will try to update it time by time (if I have enough time to work on it :) )

I did some changes on usability so user can define which of the additional information are to be shown in the textfile. For now only the 2nd line can be modified by changing the settings in the NowPlaying.vbs

I hope you enjoy this first script release of mine :)

Code: Select all

New code below
Last edited by margu on Thu Dec 15, 2005 6:02 pm, edited 1 time in total.
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

It's worth editing earlier posts to remove old versions of the code - otherwise people will get very confused and end up with the wrong version. I always replace mine with a note saying "NEW CODE BELOW".
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
margu
Posts: 53
Joined: Thu Feb 03, 2005 3:43 am
Location: Rheinberg, Germany

Post by margu »

trixmoto wrote:It's worth editing earlier posts to remove old versions of the code - otherwise people will get very confused and end up with the wrong version.
You are right trixmoto, and I'm always willed to learn :wink: and did the changes.

Thanks
..::Margu::..
popper
Posts: 34
Joined: Mon Feb 21, 2005 5:10 pm
Location: Germany

Post by popper »

This is a really cool script. I've been using the first version for some time now and it always bugged me that I had to manually start the script to get the correct song in my .sig.

One small thing though:
LoopScript = SDB.ApplicationPath&"Scripts\playing2.vbs"
should probably read instead:
LoopScript = SDB.ApplicationPath&"Scripts\NowPlaying2.vbs"
Oh, and while I am at it, two questions:
- would it be possible to only write to the file if the song has changed? Right now, it just writes every 10 sec or so which is probably unnecessary.
- where has the album information gone? ("now playing: x - y from z")

EDIT:
I'm referring to this "old version" of the NowPlaying script that I have been using:

http://www.mediamonkey.com/forum/viewtopic.php?t=5404

Perhaps you can use the "album name" routine that has been implemented there.

--
listening: Oasis - Dont Look Back In Anger
my rating: 2,5 of 5 stars / MediaPlayer: MediaMonkey 2.5.1
margu
Posts: 53
Joined: Thu Feb 03, 2005 3:43 am
Location: Rheinberg, Germany

Post by margu »

popper wrote:This is a really cool script. I've been using the first version for some time now and it always bugged me that I had to manually start the script to get the correct song in my .sig.

One small thing though:
LoopScript = SDB.ApplicationPath&"Scripts\playing2.vbs"
should probably read instead:
LoopScript = SDB.ApplicationPath&"Scripts\NowPlaying2.vbs"
Oh, you're right. I didn't check when I changed it from my working copy
popper wrote:Oh, and while I am at it, two questions:
- would it be possible to only write to the file if the song has changed? Right now, it just writes every 10 sec or so which is probably unnecessary.
- where has the album information gone? ("now playing: x - y from z")
In the new (beta) version of my script that I'll post below, I implemented the possibility to choose if the script only will run once or in a loop.
For the album information I only use rude AlbumName for now. But I'm working to implement such an AlbumArtist/AlbumName function like in the other script you referred below.
popper wrote:EDIT:
I'm referring to this "old version" of the NowPlaying script that I have been using:

http://www.mediamonkey.com/forum/viewtopic.php?t=5404

Perhaps you can use the "album name" routine that has been implemented there.

--
listening: Oasis - Dont Look Back In Anger
my rating: 2,5 of 5 stars / MediaPlayer: MediaMonkey 2.5.1
Post Reply