Reputation: 63
I'm curious to see if there's a simple way to control music through PowerShell.
I have Windows10, so Media Player doesn't really exist anymore. My default music player is MediaMonkey, but in the HKLM it didn't really have anything obvious I could hook into.
I've found a couple pages that have hinted at a solution, but nothing is producing music.
This is the closest code I've seen so far:
$PLAYER=NEW-OBJECT -ComObject 'Mediaplayer.Mediaplayer'
$PLAYER.Filename=$Filename
$Player.Play()
but this doesn't play any music.
To find out what is available to me I ran this command:
get-childitem | ? {$_.name -like "*MediaMonkey*"}
and got:
Hive: HKEY_LOCAL_MACHINE\Software\Classes
Name Property
---- --------
MediaMonkey (default) : MediaMonkey Windows 7 Controller
MediaMonkey.APLFile (default) : APL Audio File
MediaMonkey.ASXFile (default) : ASX Audio File
MediaMonkey.CDAFile (default) : CDA Audio File
MediaMonkey.FLAFile (default) : FLA Audio File
MediaMonkey.ISMAFile (default) : ISMA Audio File
MediaMonkey.M3U8File (default) : M3U8 Audio File
MediaMonkey.M3UFile (default) : M3U Audio File
MediaMonkey.M4BFile (default) : M4B Audio File
MediaMonkey.MACFile (default) : MAC Audio File
MediaMonkey.MMDCFile (default) : MMDC Audio File
MediaMonkey.MMIPFile (default) : MediaMonkey Package File
MediaMonkey.MP+File (default) : MP+ Audio File
MediaMonkey.MP3File (default) : MP3 Audio File
MediaMonkey.MPPFile (default) : MPP Audio File
MediaMonkey.MPVFile (default) : MPV Audio File
MediaMonkey.OGGFile (default) : OGG Audio File
MediaMonkey.PLAFile (default) : PLA Audio File
MediaMonkey.PLSFile (default) : PLS Audio File
MediaMonkey.QTFile (default) : QT Audio File
MediaMonkey.VQFFile (default) : VQF Audio File
MediaMonkey.WAVFile (default) : WAV Audio File
MediaMonkey.WAXFile (default) : WAX Audio File
MediaMonkey.WMAFile (default) : WMA Audio File
MediaMonkey.X-DIVXFile (default) : X-DIVX Audio File
MediaMonkey.XSPFFile (default) : XSPF Audio File
MediaMonkey.XVIDFile (default) : XVID Audio File
Any help is greatly appreciated!
Upvotes: 5
Views: 840
Reputation: 47802
From MediaMonky's Introduction to scripting page (see the About external scripts and applications header):
MediaMonkey exposes an API via the Microsoft COM model. This allows external applications to access and control MediaMonkey directly. These applications can be written in any language that can access COM objects.
PowerShell definitely qualifies.
Converting the VBScript example on that page, the code in PowerShell would be something like this:
$sdb = New-Object -ComObject SongsDB.SDBApplication
$sdb.ShutdownAfterDisconnect = $false
You'll have to play around with the object to find the properties/methods you need to control it, but it looks pretty straightforward.
Also see Interaction with MediaMonkey from outside.
Upvotes: 1