I want to make a VBScript to control Windows Media Player

Hi all, 
I'm able to control WMP through the shell but I think is not the cleanest 
solution.
Can anybody help me on how to make the VBScript to use the WMP 
Activex or COM automation?
I've found some reference about Player object and WMPLib but so far I've 
been getting compile or run time errors.
the actions I want to do are:
1. Open the file I want to play
2. Start play
3. wait 10 seconds.
4. Pause/Stop play
5. wait 10 seconds.
6. return to step no. 2.

I would appreciate your help very much. Regards.
-- 
God grants us all at the cost of effort.
0
Utf
12/3/2009 12:29:06 AM
scripting.vbscript 564 articles. 0 followers. Follow

7 Replies
7117 Views

Similar Articles

[PageSpeed] 34

Il giorno Wed, 2 Dec 2009 16:29:06 -0800, =?Utf-8?B?bG1zYg==?=
<lmsb@discussions.microsoft.com> ha scritto:

>Hi all, 
>I'm able to control WMP through the shell but I think is not the cleanest 
>solution.
>Can anybody help me on how to make the VBScript to use the WMP 
>Activex or COM automation?
>I've found some reference about Player object and WMPLib but so far I've 
>been getting compile or run time errors.
>the actions I want to do are:
>1. Open the file I want to play
>2. Start play
>3. wait 10 seconds.
>4. Pause/Stop play
>5. wait 10 seconds.
>6. return to step no. 2.

Start with this

Set Player = createobject("Wmplayer.OCX.7") 
Player.url =  "C:\BOB.MP3"  
wscript.sleep 10000
msgbox "end"

-- 
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
-- 
0
noone
12/3/2009 9:51:26 PM
To Reventlov,
   Thanks very much!
It works great!   Now I have the control!    Thanks!!!

One question if I may... the key line is: 
>Set Player = createobject("Wmplayer.OCX.7")
what is the number 7 for?
-- 
God grants us all at the cost of effort.


"Reventlov" wrote:

> Il giorno Wed, 2 Dec 2009 16:29:06 -0800, =?Utf-8?B?bG1zYg==?=
> <lmsb@discussions.microsoft.com> ha scritto:
> 
> >Hi all, 
> >I'm able to control WMP through the shell but I think is not the cleanest 
> >solution.
> >Can anybody help me on how to make the VBScript to use the WMP 
> >Activex or COM automation?
> >I've found some reference about Player object and WMPLib but so far I've 
> >been getting compile or run time errors.
> >the actions I want to do are:
> >1. Open the file I want to play
> >2. Start play
> >3. wait 10 seconds.
> >4. Pause/Stop play
> >5. wait 10 seconds.
> >6. return to step no. 2.
> 
> Start with this
> 
> Set Player = createobject("Wmplayer.OCX.7") 
> Player.url =  "C:\BOB.MP3"  
> wscript.sleep 10000
> msgbox "end"
> 
> -- 
> Giovanni Cenati (Bergamo, Italy)
> Write to "Reventlov" at katamail com
> http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
> -- 
> .
> 
0
Utf
12/4/2009 5:52:01 PM
lmsb wrote:
> Can anybody help me on how to make the VBScript to use the WMP 
> Activex or COM automation?

hi imsb,

This is a bit of an extension of the script already given,
with a couple of extra "bells-and-whistles":

--- <code> ---
' windows media player test script, jw 02Dec09

Dim oWMP : Set oWMP = CreateObject("WMPlayer.OCX.7")

   With oWMP  ' saves typing
     .settings.autoStart = True
     .settings.volume = 50  ' 0 - 100
     .settings.balance = 0  ' -100 to 100
     .settings.enableErrorDialogs = False
     .enableContextMenu = False
     .URL = "c:\windows\desktop\AlmaMater.mp3"
     WScript.Sleep(8000)  ' time to load and start playing
     .Controls.Pause()  ' stop
     WScript.Sleep(5000)
     .Controls.Play()  ' go again
     WScript.Sleep(5000)
   End With

MsgBox "if WMP is still playing, clicking OK will end it", _
     vbInformation, "WMP Demo finished"

' note: With WMP running, and no set = nothing or quit
'   statement, then the script will not end until the
'   mp3 stops playing, and maybe not even then.  If you
'   want to be SURE, then look to catch some event fired
'   when the music ends.  I suggest the "EndOfStream"
'   event, but confess that I haven't tried it...
Set oWMP = nothing
WScript.Quit
--- </code> ---

It should be noted that there are TWO WMP controls,
at least on my (win98) system.

An "old" wmp, found in msdxm.ocx with a progid of:

   "MediaPlayer.MediaPlayer.1"

And a "new" wmp, found in wmp.dll, with a progid of:

   "WMPlayer.OCX.7"

Apparently the "left-over" WMP control is associated with
an older version of wmp, and was not de-installed when the
newer version came out.

cheers, jw
____________________________________________________________

You got questions?  WE GOT ANSWERS!!!  ..(but, no guarantee
    the answers will be applicable to the questions)



0
mr_unreliable
12/4/2009 6:02:45 PM
Thanks very much. Mr. Unreliable!

I will try the code!
-- 
lmsb (Tijuana, Mexico)
God grants us all at the cost of effort.


"mr_unreliable" wrote:

> lmsb wrote:
> > Can anybody help me on how to make the VBScript to use the WMP 
> > Activex or COM automation?
> 
> hi imsb,
> 
> This is a bit of an extension of the script already given,
> with a couple of extra "bells-and-whistles":
> 
> --- <code> ---
> ' windows media player test script, jw 02Dec09
> 
> Dim oWMP : Set oWMP = CreateObject("WMPlayer.OCX.7")
> 
>    With oWMP  ' saves typing
>      .settings.autoStart = True
>      .settings.volume = 50  ' 0 - 100
>      .settings.balance = 0  ' -100 to 100
>      .settings.enableErrorDialogs = False
>      .enableContextMenu = False
>      .URL = "c:\windows\desktop\AlmaMater.mp3"
>      WScript.Sleep(8000)  ' time to load and start playing
>      .Controls.Pause()  ' stop
>      WScript.Sleep(5000)
>      .Controls.Play()  ' go again
>      WScript.Sleep(5000)
>    End With
> 
> MsgBox "if WMP is still playing, clicking OK will end it", _
>      vbInformation, "WMP Demo finished"
> 
> ' note: With WMP running, and no set = nothing or quit
> '   statement, then the script will not end until the
> '   mp3 stops playing, and maybe not even then.  If you
> '   want to be SURE, then look to catch some event fired
> '   when the music ends.  I suggest the "EndOfStream"
> '   event, but confess that I haven't tried it...
> Set oWMP = nothing
> WScript.Quit
> --- </code> ---
> 
> It should be noted that there are TWO WMP controls,
> at least on my (win98) system.
> 
> An "old" wmp, found in msdxm.ocx with a progid of:
> 
>    "MediaPlayer.MediaPlayer.1"
> 
> And a "new" wmp, found in wmp.dll, with a progid of:
> 
>    "WMPlayer.OCX.7"
> 
> Apparently the "left-over" WMP control is associated with
> an older version of wmp, and was not de-installed when the
> newer version came out.
> 
> cheers, jw
> ____________________________________________________________
> 
> You got questions?  WE GOT ANSWERS!!!  ..(but, no guarantee
>     the answers will be applicable to the questions)
> 
> 
> 
> .
> 
0
Utf
12/4/2009 7:36:01 PM
Il giorno Fri, 4 Dec 2009 09:52:01 -0800, =?Utf-8?B?bG1zYg==?=
<lmsb@discussions.microsoft.com> ha scritto:

>To Reventlov,
>   Thanks very much!
>It works great!   Now I have the control!    Thanks!!!
>
>One question if I may... the key line is: 
>>Set Player = createobject("Wmplayer.OCX.7")
>what is the number 7 for?

I found the name "wmplayer.ocx.7" in the registry. From a certain version of MediaPlayer
Microsoft provided this new version of the activeX component.

I found some information on how to use this com object in a file called wmpsdk.chm in a cd
shipped together with a book about MediaPlayer.
I borrowed the book from  the public library. It did not tell much about programming. Only
about deploying, skins  and custom installation of MediaPlayer.
But in the cd there was some other stuff.
Maybe you can find this file in ms site.
Dated 24 june 2000, it's a 1,02 Mb file.

Giovanni.

-- 
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
-- 
0
noone
12/4/2009 9:53:25 PM
Il giorno Fri, 04 Dec 2009 13:02:45 -0500, mr_unreliable
<kindlyReplyToNewsgroup@notmail.com> ha scritto:

>lmsb wrote:
>> Can anybody help me on how to make the VBScript to use the WMP 
>> Activex or COM automation?

>It should be noted that there are TWO WMP controls,
>Apparently the "left-over" WMP control is associated with
>an older version of wmp, and was not de-installed when the
>newer version came out.

You are right.
wmpsdk.chm says the old control is still shipped with the new version of the ocx:

What's New
Three major changes have been made in the Windows Media Player control since the last
version. 

The control has a new CLSID. It is 6BF52A52-394A-11D3-B153-00C04F79FAA6. The old control
is still shipped with this version to ensure that previous Web pages function correctly.
But if you want to take advantage of the new functionality of the control for this
version, you must change your CLSID.

The control has been split into subcontrols, including Controls, Settings, and Network.
Methods, properties, and events that are attached to the main control are documented under
the Player object. See the Control Reference for more information. Methods and properties
of the subcontrols are accessed through the player. For example, to use the bandWidth
property of the Network object, you must type: 
player.Network.bandWidth

The following methods and properties are no longer supported in this version of the
Windows Media Player control: 
AboutBox [....................]


-- 
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
-- 
0
noone
12/4/2009 10:00:17 PM
lmsb wrote:
> One question if I may... the key line is: 
>> Set Player = createobject("Wmplayer.OCX.7")
> what is the number 7 for?

hi lmsb,

The number "7" in the progid is just a version number.

Most likely, you will find the "generic" progid in
your registry, which is "WMPlayer.OCX".  You could
use that in your script.  Part of the "generic" entry
is the "CurVer" (current version) key, which on my
system is "WMPlayer.OCX.7", i.e., version 7.  And so,
if you use the generic progid or the version-specific
progid, you get the same actx object (at least on my
system.

However, if ms comes out with a newer version, and
especially if the new version has different methods
and properties, then the version number WILL make
a difference.

cheers, jw
____________________________________________________________

You got questions?  WE GOT ANSWERS!!!  ..(but, no guarantee
    the answers will be applicable to the questions)

0
mr_unreliable
12/5/2009 2:00:43 AM
Reply:

Similar Artilces:

want questions
Hello Everyone, I want some set of questions on Word-2007 to check competency level of the user. Please help. -- Ananta Gupta Ananta, please refer to my other 2 postings: just check out the WORD part. If my comments have helped please hit Yes. Thanks. "Ananta Gupta" wrote: > Hello Everyone, > > I want some set of questions on Word-2007 to check competency level of the > user. Please help. > > -- > Ananta Gupta "trip_to_tokyo" wrote: > Ananta, please refer to my other 2 postings: just check out the WOR...

I want more!
I need to extend a form that aleady has some 100 lines. For instance, one column has the date, but only until tomorroq. How do I create more lines based on the same formula? Thank you JB I usually select the last row in the range and copy it down a few rows. If you're using xl2003, you may want to look at Data|List. And if you're using xl2007, this feature has transformed into Tables. (Data tab on the ribbon|Data tools Group|What if Analysis|Data table) JB wrote: > > I need to extend a form that aleady has some 100 lines. For instance, one > column has the da...

Renewing SSL (Windows CA)
I am looking to request a renewal for our SSL certificate within the IIS Manager in relation to our Exchange2003/Outlook RPC client connections. The question I have is when I go thru the steps to renew the current certificate, will it void (at any time) the current certificate that our remote RPC clients are using? I am looking for this to be somewhat seemless and keep the attrition to a minimum. After we get this cert updated we'll be looking to into a signed cert from the likes of Verisign, etc... Until then though, we need to get it updated due it's expiring in the next f...

Windows Mail in W7
When I installed Windows 7 on my laptop, I also moved my Windows Mail to it. I was provided with 2 patches to make it run correctly. I applied the 1st one, but not the 2nd (I don't remember why). I have been using Windows Mail successfully for months now, with annoying limitations. Does anyone have the link to those patches so I can download them again. I think they made changes to the registry. TIA, Paul This is the procedure that worked for me: 1. Rename the C:\Program Files\Windows Mail\ directory in Win7 to = something else. 2. Copy that same-named directory (inc...

Window position on the monitor
Is there a way to set the default position on the monitor for a new window, such as starting a new email message? Currenly a new window goes to the upper left corner, & I would like it in the center. Thanks, Pat On 12/8/07 11:54 AM, in article 598a4a61-1f59-419f-a281-614a7f1a7358@w28g2000hsf.googlegroups.com, "patrick.cashen@gmail.com" <patrick.cashen@gmail.com> wrote: > Is there a way to set the default position on the monitor for a new > window, such as starting a new email message? Currenly a new window > goes to the upper left corner, & I would like it in...

How to make a hollow line?
Is there some way to make a line shape hollow? That is, make it have a border (like a rectangle shape) with a center that I can change with the fill property? I want to build various structures that connect at odd angles. Lines are perfect because thay can be attached to anything at any angle, but I don't want a solid black line and I don't want a lighter color without a border. I tried using a shape (rectangle or oval) but using the rotate tool to get odd angles is not as convenient as connecting lines. Thanks -- Using Visio Standard 2002 on Win 2000 Draw your rectangle then r...

need to make 3 fields into 1 field
I have an mail list that has been created with 3 address fields. These fields need to be consolidated into 1 field. Can this be done. Thanks try =a1 & " " & b1 etc -- Don Guillett SalesAid Software donaldb@281.com "Georgia" <Georgia@discussions.microsoft.com> wrote in message news:967B03F1-717D-47BB-80D6-3A289DCAC1A8@microsoft.com... > I have an mail list that has been created with 3 address fields. These > fields need to be consolidated into 1 field. Can this be done. > > Thanks > Georgia Most programs that use Adresses like them ...

Best Windows 7 group?
I've used this forum several times to solve XP probs and found the people here extraordinarily helpful in ironing out my special (often self-caused) bugs. Now I've moved to Windows 7 Ultimate and am wondering if anyone can suggest a similar Google-accessible newsgroup which could be similarly useful. I've tried the moderated group just called 'windows 7' but get the idea that no-one there really knows the system in-depth the way people here understand XP. Best wishes "anthony" <anthonyjhcnospam@netscape.net> wrote in message news:16a9cd19-6a6b-...

Using MFC ActiveX control in ASP
I'm using VS.Net 2003 to create a very simple ActiveX control in MFC. The control has no ui and just a few properties and methods. What do I need to do to make it work in a classic ASP page? Currently any time I try to set a property on my control {after calling 'Set obj = Server.CreateObject(...)'} I get this error: Error Type: (0x8000FFFF) Catastrophic failure I can successfully use my control from a C# Winforms app. What am I missing? -Brett- > What do I need to do to make it work in a classic ASP page? It needs a standard COM and/or an IDispatch interface. Does i...

How to dsiplay Word Document inside a control in WinForms Applicat
Can I display word document in Windows Form Panel Control or any other control ? Here objective is not display word document as seperate application but show the word document inside the windows Form. Thanks, --Israr Hi, I think we can do this using OLE control(VB). Thanks, Senthil. S -- senthilkumarabi ...

I don't want a page of the same label, I want one of each...
I can't find where to tell Pubisher that I want one of each label and not a page of each label. I'm using Publisher 2003 (Office 2003) I see a post that says to enter "<<Next Record>>" but Publisher doesn't see this as a field, just as text. This can't be that hard, but I can't figure it out... Any help would be appreciated. Kelvin I see that it prints correctly, but the print preview displayes it wrong.... I think I have it figured out... "Kelvin" <someone@domain.com> wrote in message news:OSpLwThUIHA.5508@TK2MSFTNGP04.phx....

Makeing People Save As
I have an excel spreadsheet on a shared drive at work. When people in the office open the file, is there a way to make them "save as" and not to be able to type on the original file? Thanks for any help in advance!!! Eric "=?Utf-8?B?RXJpYw==?=" <Eric@discussions.microsoft.com> wrote in news:CCD79852-03E2-4980-B533-6EAFC253A009@microsoft.com: > I have an excel spreadsheet on a shared drive at work. When people in > the office open the file, is there a way to make them "save as" and > not to be able to type on the original file? > > Th...

Do I need to use VBA for the following control structure?
Hi all, I have the following control structure from Matlab, do you think I need VBA to handle it, or I can just rely on Excel? Thanks a lot! ----------------------------------------- for t=1:5; CumLoss=CumLoss+sum(DefaultTime(:, t)); if (CumLoss>TotalNotional*Deattachment) break; else PV=PV+y*(TotalNotional-CumLoss)/(1+r)^t; if t==5 PV=PV+(TotalNotional-CumLoss)/(1+r)^t; end; end; end; You can just rely on Excel: In row 1 put the labels t,DefaultTime, CumLoss,PV,TotalNotional,D...

RPC over HTTP on Windows 2000 Pro
Hi all, Can anyone confirm that I will be able to use Outlook 2003 via RPC over HTTP on Windows 2000 Professional please? Many thanks, Mike In news:8A9F1E1B-36EA-470F-ADC9-6E044FC31D31@microsoft.com, Mike K <MikeK@discussions.microsoft.com> typed: > Hi all, > > Can anyone confirm that I will be able to use Outlook 2003 via RPC > over HTTP on Windows 2000 Professional please? > > Many thanks, > Mike Sorry; you'll need Windows XP SP1 or SP2 to do this. http://office.microsoft.com/en-us/assistance/HA011402731033.aspx ...

Visual controls
Where can I found and install more GUI controls for VC6? I need something like TPanel in Borland (Delphi or C++ Builder) tools. I need to make small blue rectangle around picture and WebBrowser control. Which GUI control is the best for it? I've tried to use CStatic, but it is allways showing in a front of WebBrowser control. :( How can I "sent it" to background? Petar, CStatic would do fine. You'll have to be aware, however, that in MSVC++ 6.0, the controls are created in the reverse order from the resource editor, so you should place the static on top of the ...

ethernet controller issue
hi, i posted previously but need to clarify. my device mgr indicates no driver installed for my ethernet controller (NOT the ethernet adapter) as well as the video and audio controller (i can't hear sound from my media player either.) it seems that the controller and adapter are two different things - the ethernet adapter is above the ethernet controller in the device mgr, but only the controller has a yellow question mark (shown as under 'other devices.') along with the audio and video controller. i understand that an ethernet controller has two other names: a &qu...

Lebans tooltip control 10-28-07
I am trying to use the tooltip control on a form with a tab control, on which are the other controls I want to show information for. On controls that are outside the tab control, it works fine; on controls inside the tab control, the tooltip shows on text boxes only when they have the focus, and on check boxes not at all. I've tried every naming scheme for controls I can think of, without any luck. Anybody have any ideas about this??? Is it the same problem as using a subform???? I am using ACCESS 2003 -- Jack Walsh ...

Text want wrap in text box
I can't get the text to wrap in a text box, word wrap is set to true, I put some text boxes on a sheet today and the text will not wrap, I did this yesterday and it worked fine, I can copy the ones from yesterday and paste them on a new sheet and they work, any ideas? I have rebooted but this did not help. Using Excel 2000 (9.0.6926 SP3) Thanks Paul B If you're referring to a Control Toolbat text box make sure that the MultiLine property is True. -- Jim Rech Excel MVP "Paul B" <pbridgesnews@uga.edu> wrote in message news:%23ovLUkuLEHA.2456@TK2MSFTNGP12.phx.gbl......

I want to add a sound event when the cursor bumps left margin
I want to know (via an event sound) that my cursor movement has bumped the left edge of the spreadsheet. I am entering thousand of rows of data, and it would help if there was a event sound when I returned the cursor to the left edge. I have this feature in 123, and find it helpfull. Put this in the sheet module: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Static ColOld As Integer If Target.Column = 1 And ColOld > 1 Then Beep ColOld = Target.Column End Sub -- Earl Kiosterud mvpearl omitthisword at verizon period net ------------------------------------------- "m...

create SPC chart with 3 sigma Upper/Lower control limit
Hi all How can I create a Statistic Process Control chart with 3 sigma Upper control limit and 3 sigma Lower control limit. The chart must be updated with new data. For example sale vs month chart for sale department and I know some data for last year. Must be some where have this tutorial please respond with the link. Thks Daniel http://peltiertech.com/Excel/Charts/RunChtLines.html Change the formulas to get �3 SD instead of �SD. - Jon ------- Jon Peltier, Microsoft Excel MVP Tutorials and Custom Solutions Peltier Technical Services, Inc. - http://PeltierTech.com _______ "D...

How Can I make a cell flash in Excel
I am looking to highlight certain cells in a column of data and would be helpful to make them flash, as oposed to just standard formatting Hi flashing would require VBA (using for example the OnTime method). But I strongky recommend against it: - slows down Excel - has IMHO nothing to do with serious spreadsheets - requires VBA and won't work if macros are disabled If you still want to go on with this search the Google archives for 'blinking cell' "Cumbo" wrote: > I am looking to highlight certain cells in a column of data and would be > helpful to make them ...

Want to Add more Sub description Field
How I can add more sub description field like 1,2,3,4,5 regards Saleem Suri Salaam Saleem, You have only limit up to 3 fields in RMS 1,2,3 sub-description also you can use the extended description and there is main description for the item. so Altogether you have upto 5 description limit and I think that is enough. Let me know if this won't fulfill your requirements else use the Item Notes for more description. Rate if like Regards Akber "Saleem Suri" wrote: > How I can add more sub description field like 1,2,3,4,5 > > regards > Saleem Suri Salam Akbar ...

Exchange 2003 server is a domain controller
Exchange 2003 on Win 2k Ent, 2 other DCs running Win 2003, single domain. The previous admin here made the exchange box a domain contoller. It's having some DNS problems looking for an old DC that doesn't exist anymore, log in issues etc. I'd like for it not to be a DC at all. The problem is that when I demote it from being a DC, no mail flows at all and OWC connections quit. Can someone explain to me why mail stops and what needs to happen for me to fix this? This is my last Win 2k box and I'm leary of trying to upgrade it in it's current condition. On Thu, 8 F...

how can make a mail copy to a group
i using win 2003 , exchange 2003 if have a user mail need forward ( make a copy ) to many users how can i do this ? i just know how to make a copy to one copy thx On Sat, 12 Mar 2005 01:03:12 +0800, "tequila" <tequila529@gmail.com> wrote: >i using win 2003 , exchange 2003 >if have a user mail need forward ( make a copy ) to many users >how can i do this ? > >i just know how to make a copy to one copy >thx > > Have you looked at creating a Dirstribution Group within Active Directory Users & Computers? You can mail enable it and make a number of...

Excel wants to create a page break in every cell!
After saving revisions in an Excel worksheet, I get a popup message that states "Margins do not fit page size". After clicking "ok" (because this is my only choice) a page break is automatically created in ever cell. At times(depending on the sizeof the work sheet) it can be over 100 pages with a page size 14% or smaller. Why does this happen, and how can I avoid it? I saw this suggestion in a different forum. Try closing excel. Clean up your windows temp folder Windows start button|Run type: %temp% and hit enter Clean all those files that you ca...