Question/Bug for the MM team

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

Moderators: Peke, Gurus

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Question/Bug for the MM team

Post by trixmoto »

I have stripped down my code as much as possible to highlight this bug for you.

The first script is a ScriptType=2 so runs when a track plays. All it does is look for and run a second script file.

Code: Select all

Sub CueReader
  cuef = SDB.ApplicationPath&"Scripts\CueReader2.vbs"
  If SDB.Tools.FileSystem.FileExists(cuef) Then
    Set WShell = CreateObject("WScript.Shell")
    line = "wscript "&Chr(34)&cuef&Chr(34)
    res = WShell.Run(line, 1, 1)
  End If
End Sub
Then the second script (CueReader2.vbs) contains a simple loop which will continue whilst the player is playing.

Code: Select all

Set SDB = CreateObject("SongsDB.SDBApplication")
Do while SDB.Player.isPlaying  
  WScript.Sleep 200
Loop
Now try this:
1) Play a file so the first script starts (which starts the second script and ends).
2) Click on some node/playlist so another track appears in the library window.
3) Press stop on the player (which ends the second script).

The song that is first in the library window will now start playing. It doesn't always happen. But about 80% of the time it does. Any ideas?
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.
psyXonova
Posts: 785
Joined: Fri May 20, 2005 3:57 am
Location: Nicosia, Cyprus
Contact:

Post by psyXonova »

Well Trix, you post troubled me....
So i digged a bit.

I tried the following code

Code: Select all

Sub CueReader
  cuef = SDB.ApplicationPath&"Scripts\CueReader2.vbs"
  If SDB.Tools.FileSystem.FileExists(cuef) Then
    Set WShell = CreateObject("WScript.Shell")
    line = "wscript "&Chr(34)&cuef&Chr(34)
    res = WShell.Run(line, 1, 1)
  End If

MsgBox "Cue Reader just finished"
End Sub
And

Code: Select all

Set SDB = CreateObject("SongsDB.SDBApplication")
Do while SDB.Player.isPlaying 
  WScript.Sleep 200
Loop 

MsgBox "Monitor just finished"
Guess what, monitor was exiting before the cuereader, since the first script was paused while the second was running. After the monitor exits the first script reevaluates the if statement, causing the the second script to run again and also causing the MM player to restart.
Now, i dont know why this happens only if the current songlist has changed. Perhaps its a bug...

The point is that i found a workaround

if you execute the second script like this

Code: Select all

    res = WShell.Run(line, 1, 0)
Then, the first script dont wait for the second and terminates. This eliminates this bug

Hope this helps
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Cheers, once again you have prevailed! :)
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.
Peke
Posts: 18372
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

Code: Select all

WShell.Run(line, 1, 0)
Is windows command and when it is executed that way it waits for return Command :) No bug there.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
psyXonova
Posts: 785
Joined: Fri May 20, 2005 3:57 am
Location: Nicosia, Cyprus
Contact:

Post by psyXonova »

yes Peke, but the question is...
why does the playback starts after all?
and why does this happens only on node change?
It may not be a bug, but is quite strange

@Trix
Just glad to be of help Trix. Sometimes when you have written 1000 lines of code is hard to realize where the problem resides. A look from a second codes is always better in those occasions, thats why i solved that problem of yours. All credits to you!!!
Peke
Posts: 18372
Joined: Tue Jun 10, 2003 7:21 pm
Location: Earth
Contact:

Post by Peke »

yes Peke, but the question is...
why does the playback starts after all?
It is On Play Script not On track Change script.

Its better said Pre-Play Script.
and why does this happens only on node change?
Explain that.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
Image
How to attach PICTURE/SCREENSHOTS to forum posts
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Ok, the three arguments for the Run method.

1) The command string
2) A number which represents the window style.
3) Whether the script should wait for a response (true/false)

What do the window style numbers respresent?

ADDITION: Having searched for AGES through a lot of rubbish, I found this rather useful link: http://www.ss64.com/wsh/run.html
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.
jiri
Posts: 5430
Joined: Tue Aug 14, 2001 7:00 pm
Location: Czech Republic
Contact:

Post by jiri »

It seems to be the same parameter as SW_ constants in e.g. ShowWindow() WinAPI function, so in case you need it, more details could be found in MSDN.

Jiri
psyXonova
Posts: 785
Joined: Fri May 20, 2005 3:57 am
Location: Nicosia, Cyprus
Contact:

Post by psyXonova »

Trix, there is a detailed description of each command inside Microsoft's Scripting Guide.
You can download it from srcipting.microsoft.com
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Post by trixmoto »

Thanks. Here is a more direct link for anyone who is interested: http://www.microsoft.com/downloads/deta ... laylang=en
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.
Post Reply