Brazil
Asked — Edited

Control Windows Media Player

Friends, how can I control the windows media Player (or the Itunes) from ARC ? I want my robot (that has an PC inside) to play my sound library, and of course I can not put 3000 songs into an SoundBoard command... Can I ? thanks! tevans


ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

United Kingdom
#1  

Quote:

Exec( EXE/Bat File, [parameters] )

     Executes a windows application or batch file. The second parameter is a list of optional parameters

     Example: Exec(C:\Windows\Notepad.exe)

     Example: Exec(C:\Windows\Notepad.exe, C:\MyFile.txt)

Since I haven't used WMP or iTunes for over a decade I don't know if it has any command line parameters like other media players do, but that (or this along side a auto hot key script) is likely the best method of controlling an external application.

#2  

Steve g did something similar in a post. He might chime in.

Brazil
#3  

got it! I think this will run the program, rigth?

but how do I control the Play, Stop, next, shuffle, etc... ?

thanks!

#4  

It's a pain in the hinny, you can't open the Windows Media Player directly from the Exec command.

But what you can do is create a batch file to control the media player to do what you what. You can run the batch file from the Exec command in ARC. It's very easy, you just need to make one more file.

Before I explain how, it's important to know you won't be able to control a lot, you can launch an individual file or a playlist and that's about it. Those limitations have more do with the Windows Media Player then ARC.

To Make a Batch File: Open NotePad.exe, you can do this by right clicking on your desktop and selecting New, then Text Document. This will create a new text file on your desktop, open it and it will launch in Note Pad by default. Enter the following and modify as needed:


"%ProgramFiles(x86)%\Windows Media Player\wmplayer.exe" "C:\Users\weyou_000\Music\Playlists\All 80's.wpl"

The first part should be the same for most users, it is the location of the Windows Media Player .exe. The second part is the location of my All 80's playlist file, you would need to change this location and name of the file or the playlist you want.

Once that is entered, click File, select Save As, set the location, name it and make sure to end the file name with .bat (not .txt). Last and most important, change the Save as type to All Files . This should create a batch file, and you can test it by double clicking on it when finished. It should launch the Media Player and the file or play list.

In ARC, create a new script and enter the following, but change the path and file name to reflect your batch file.


Exec("C:\Users\weyou_000\Documents\EZ-Builder\My Projects\BatchFiles\80's Playlist.bat")

Run the script and Media Player should launch with your file or play list.

#5  

To Close the media player, you need to create a another batch file, follow the directions from above to make the batch file, but this time enter this code in the file:


taskkill /im wmplayer.exe

As you can see it is a lot easier to end a program than to launch it.

In ARC, make a new script and enter this code, change the path and file name to the path/file name of your batch file.


Exec("C:\Users\weyou_000\Documents\EZ-Builder\My Projects\BatchFiles\StopMediaPlayer.bat")

That's how you control the media player. There are no granular controls for scripted options to control the media player. I suspect the same is true for iTunes.

This site explains the control line options available for the media player, as you can see there are not many:
https://support.microsoft.com/en-us/kb/241422

#6  

Here's how I did it by using the PlayAudio Command. It's all good just how you want to do it ... :)

To start a music file:

Example Phrase: "Robot play music file ACDC Burning Alive"

Command: PlayAudio(d:\Music\ACDCBallBreaker\BurninAlive.mp3")

To stop a music file:

Example Phrase: "Robot stop music file"

Command:

StopAudio

The same holds true for movies if you happen to have a screen on your robot too.

Example Phrase: "Robot play movie file Star Wars.

Exec("D:\Movies\StarWars.wmv")

Note: I never knew how to stop the video player till after just reading Justin's reply so I'll give that a try next time.

#7  

Herr Ball that's another good way to play a file. I might be more inclined to add the music file to a soundboard if you wanted specific files, but your method probably makes the ezb file smaller.

What is interesting about your method, calling the file directly, is that it would open the file in whatever application you have set as the default player for the file under Windows. If you had iTunes set as the default player, it should open in iTunes which would require the batch file to be changed.


taskkill /im iTunes.exe

This will work to close iTunes from a batch file. If another program was set as the default the .exe file name would need to be located and changed in the batch file.

#8  

you can also stop iTunes from ARC without a batch file using this script,


$attributes = "/F /IM iTunes.exe"
exec("taskkill",$attributes)

David Cochran taught us that in this thread

Likewise you can stop and close Windows Media player without a batch file in ARC:


$attributes = "/F /IM wmplayer.exe"
exec("taskkill",$attributes)

#9  

And if you want to launch a playlist from Windows Media player without using a batch file you can create a shortcut under windows of your playlist. (ARC does not seem like launching a playlist directly, but it has no issues with windows Short Cut .lnk files.)

ARC script:


Exec("C:\Users\weyou_000\Documents\EZ-Builder\My Projects\ShortCuts\All 80's.lnk")

That is just another way to do it.

#10  

Oh Cool, I just realized Harr Ball's method does not launch a media player, it plays it inside ARC....didn't know it could do that like that, but it makes sense...it must treat it like it is playing a sound board file.


PlayAudio("d:\Music\ACDCBallBreaker\BurninAlive.mp3")

United Kingdom
#11  

@tevans.

Did I hear my name mentioned, lol?

Yes I did manage to find a way to play my music library via ARC. Thanks to @d.cochran and @thetechguru, I was guided to download and use WinAmp media player then set that as the default player, so everything in my iTunes and Windows libraries play through that, that was then controlled using the command prompt window where you can use controls for volume, play, pause ect.

User-inserted image

I have posted the link to that thread which should contain everything you need to know...

Playing music files through ARC

EDIT: I just re-read the whole thread as I was busy earlier, and see that @JustinRatliff posted the link to the above thread already.

#12  

BOOM! If anyone wants to control their Windows Media player with play/pause, volume up/down, stop, next track, previous track - this guy just figured out how to do that without an externally downloaded app or a different media player.

Is anyone interested in a tutorial, or should it keep a secret? :P

United Kingdom
#13  

EDIT:

Deleted irrelevant post.

@Justin.

Yes a tutorial would be great if you get a chance. :)

#14  

@Justin, Yes, if you have it figured out in wmplayer I would be interested in seeing it. I don't mind using Winamp and Clever, but I am trying to keep installed software to a minimum on my W3, so using something built into Windows would be nice.

Alan

Brazil
#15  

You are great! I'll try it rigth now!

#16  

I'm not using your method Steve G.

I'm using power shell which comes with windows. It's super easy. I'm sure your method is too, but I like using what windows provides. I'll do up a tutorial and post it soon.

United Kingdom
#17  

@justin.

The way you started post #13 sure looked like you were replying to my post. Anyway it's deleted now as its now not relevant.

Yes, it would be nice to see how you did it just using Windows.

Brazil
#19  

Please justin! A tutorial would be great!

#20  

@Technopro I shared that same info from a Microsoft kb article in post #6. That article is correct for direct control of Media Player application. But there are other control methods as you'll see in the tutorial.

@Steve G, your post was fine, you didn't need to delete it. I kinda thought you thought my post was a thank you for your method rather than announcement of a new method I found - which is fine, all methods are good. Your method will still provide more granular options like position and time left.

United Kingdom
#21  

@Justin.

No worries bud. It wasn't until I re-read the post then I saw what you meant with the mention of "no third party apps". My bad, lol. I do like your idea though. Looks a lot simpler. :)

Brazil
#22  

I could use the method in Post #10 It works... now, how to command "next Music, Shuffle, stop, etc ?" thanks guys!

#23  

That part is coming tevans, I have to edit the video and upload it so everyone can understand what I did. :)