Script associated with Special Keys to control MM?

Download and get help for different MediaMonkey Addons.

Moderators: Peke, Gurus

Script associated with Special Keys to control MM?

Postby Alex » Fri Jul 22, 2005 9:26 am

I'm not familiar with writing such scripts (Java and PHP is OK, but...)

Is it possible to write an external (windows) script to control MM, e.g. one script that makes MM to play, one script to make it stop, one to play next...
Afterwards can these scripts be run by command line?
Cause I got 4 buttons on my Lifebook, which only can be associated with commandline-commands.

I would really appreciate some Help!

Greetz, Alex
Alex
 

Postby Alex » Fri Jul 22, 2005 10:45 am

OK, what I found out so far

Code: Select all
Dim SDB
Set SDB = CreateObject( "SongsDB.SDBApplication")
While Not SDB.IsRunning
WEnd
SDB.Player.Play
SDB.ShutdownAfterDisconnect = False


starts MM and plays the enqueued song.

Is it hard to change this script , so if you run it again and MM is playing it tells MM to pause, and if MM is stopped or in Pause it tells MM to play?

I think the above code is relativly easy, but for me it's like reading ASCI.
Alex
 

Postby nostrad » Fri Jul 22, 2005 11:16 am

This should do the trick

Code: Select all
Dim SDB
Set SDB = CreateObject("SongsDB.SDBApplication")
While Not SDB.IsRunning
Wend
If SDB.Player.isPlaying And Not SDB.Player.isPaused Then
  SDB.Player.Pause
Else
  SDB.Player.Play
End If
SDB.ShutdownAfterDisconnect = False

For next track:
Code: Select all
Dim SDB
Set SDB = CreateObject("SongsDB.SDBApplication")
While Not SDB.IsRunning
Wend
SDB.Player.Next
SDB.ShutdownAfterDisconnect = False

For previous and stop simply replace SDB.Player.Next with
SDB.Player.Previous and SDB.Player.Stop respectively. Actually quite simple, when you know :P .

EDIT 1: Added next, previous and stop
EDIT 2: Fixed above code to actually work :)
nostrad
 
Posts: 11
Joined: Wed Jul 20, 2005 9:25 am
Location: Sweden

Postby Alex » Fri Jul 22, 2005 11:42 am

Thanks, I created something similar by myself after reading some references about VBScripts, but there is still a problem with my script and it's the same with yours (which I prefer).

If I start MM from the startmenu and use your script afterwards it's doing fine!
Starting MM with the script is done correctly too, but if I use it a second time to pause MM there is no reaction and an errormessage occurres:

ActiveX-Components can not create object: 'SongDB.SDBApplication'


Any suggestions?
Alex
 

Postby nostrad » Fri Jul 22, 2005 4:27 pm

Add
Code: Select all
Set SDB = Nothing

to the end of the scripts and that should do the trick.
nostrad
 
Posts: 11
Joined: Wed Jul 20, 2005 9:25 am
Location: Sweden

Postby XratedFozzibaer » Sat Jul 23, 2005 5:42 am

Thanks for your reply, I tried your suggestion, but it still doesn't work. Your approach sounds logical to me, but still the same error occures.
This is what the VBScript looks like now:
Code: Select all
Dim SDB
Set SDB = CreateObject("SongsDB.SDBApplication")
While Not SDB.IsRunning
WEnd

'MM is paused or running? Then Play or Pause!
If SDB.Player.isPlaying And Not SDB.Player.isPaused Then
  SDB.Player.Pause
Else
  SDB.Player.Play
End If

'MM should not shut down on disconnect
SDB.ShutdownAfterDisconnect = False

'disassociate object variable ("SongsDB.SDBApplication") from actual object (SDB)
Set SDB = Nothing


Still the same error message after starting MM with the script and afterwards trying to pause MM with the script:
ActiveX-Components can not create object: 'SongDB.SDBApplication'


any other suggestions?
XratedFozzibaer
 
Posts: 12
Joined: Fri Jul 22, 2005 9:15 am
Location: Bavaria

Postby nostrad » Sun Jul 24, 2005 5:55 am

I can't seem to find the reason for why this happens, it seems as if the SongsDB object can't be reached when MediaMonkey is started from a script (or a program as the same thing happens in Visual Basic). Another solution would be to find something that allows you to control winamp with those keys, as MM emulates the WinAmp API.

[EDIT]This WinAmp plugin does exactly what you want: http://www.winamp.com/plugins/details.php?id=58602 so you can use that instead.[/EDIT
nostrad
 
Posts: 11
Joined: Wed Jul 20, 2005 9:25 am
Location: Sweden

Great Plugin

Postby XratedFozzibaer » Sun Jul 24, 2005 6:38 pm

Yeah, that plugin is really great!
I kinda combined the scripts and the plugin.
Now I can start MM, start playing, pause, start playing again and skip to next track with two buttons (two scripts).

Start MM, Play, Pause VBScript
Code: Select all
'Check if mediamonkey is running
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'mediamonkey.exe'")
'MM is not running! Start it
If colProcesses.Count = 0 Then
 Set WshShell = WScript.CreateObject("WScript.Shell")
 Return = WshShell.Run("c:\programme\mediamonkey\mediamonkey.exe /nosplash", 1, true)
'MM is running! Play or Pause
Else
 Dim SDB
 Set SDB = CreateObject("SongsDB.SDBApplication")
 While Not SDB.IsRunning
 WEnd
 'MM is paused or running? Then Play or Pause!
  If SDB.Player.isPlaying And Not SDB.Player.isPaused Then
   SDB.Player.Pause
  Else
   SDB.Player.Play
  End If
 'MM should not shut down on disconnect
  SDB.ShutdownAfterDisconnect = False
 'disassociate object variable ("SongsDB.SDBApplication") from actual object (SDB)
  Set SDB = Nothing
End If

The path to MM has to be set in this script.

To skip to the next song I use the plugin (but it could be done with the script shown in a post above, too)

Thanks for all your suggestions!!!
Alex a.k.a. lxne
---------------------------
http://www.lxne.eu
MBP, OSX Leopard
XratedFozzibaer
 
Posts: 12
Joined: Fri Jul 22, 2005 9:15 am
Location: Bavaria


Return to Need Help with Addons?

Who is online

Users browsing this forum: No registered users and 10 guests