Click here to Skip to main content
15,501,036 members
Articles / Desktop Programming / WTL
Posted 23 May 2005


32 bookmarked

Windows Media Player Standby Plug-in

Rate me:
Please Sign up or sign in to vote.
4.47/5 (13 votes)
27 May 2005CPOL4 min read
Media Player plug-in turning computer off when media ends
In this article, you will see my implementation which is similar to the TV's Sleep timer function. You will also see my Media Player plug-in which instead of turning Media Player off after the specified interval of time turns the PC off when the media ends.

Sample Image


Recently, I found Media Player Sleep Timer in the Media Player Bonus Pack for Windows XP (or Power Toys or something like that). That plug-in is similar to the TV's Sleep timer function, which turns TV off after some interval, set by user - so it closes Media Player after the interval set. And I decided to implement a similar functionality for my PC - and wrote this Media Player plug-in which instead of turning Media Player off after the specified interval of time turns the PC off when the media ends. For example, you can load playlist with your favorite music, or play a DVD movie, etc., start this plug-in, and go to bed. After the movie (music file, playlist, etc.) ends, your PC either shuts down or logs off or hibernates/suspends, depending on your settings. It can also mute sound during shutdown operation. Frankly speaking, I don't know if it really is a timer at all, but no matter.


If you are unfamiliar to Media Player plug-ins, then you should read the Microsoft Windows Media Player SDK Help first. In short, the Windows Media Player plug-ins are COM objects, allowing to extend its architecture. This ATL DLL contains only two types of plug-ins: the user interface plug-in and the background plug-in. The user interface plug-in creates a window in the Media Player Settings area of the full mode player, allowing the user to manage global settings - so it tells to the background plug-in (which is running constantly after the Player starts) whether to listen to the Media Player events or not, and sets the type of Standby Mode (PowerOff/LogOff/Hibernate/Suspend) and Mute Sound (On/Off). The background plug-in runs in the background (as it follows from its name), and listens to the Media Player events. When the media end event is triggered, it mutes sound and shuts down the PC if the user enabled these features through the UI plug-in.

The main problem was communication between these two plug-ins - Media Player does not give you the interface pointers to the plug-in instances. But I remembered that both plug-ins are in the same DLL, and the Player instance is limited to a single one, so just created the shared data segment. The UI plug-in just sets the mode variables in the shared section, and the background plug-in just reads them. That's all.

The setup inf file is also included in the project. You can build a small setup EXE with the IExpress utility. IExpress is included with Microsoft Internet Explorer Administration Kit - it allows to build small and fast setup packages.

Image 2

Program Setup

After running the setup.exe or just registering the plug-in DLL (with regsvr32.exe), open Media Player. From the Tools menu, select Options. After the Options property sheet is displayed, navigate to the Plug-Ins tab, select Background in the list of the plug-ins, and check Armen Hakobyan's Background Sleep Timer. This will load the background plug-in in case it is not loaded automatically. Then, to display the UI plug-in, switch Media Player to full mode, go to the View menu, and from its Plug-Ins submenu, select Armen Hakobyan's Sleep Timer.

Program Requirements

Project Dependencies



  • 18th May, 2005
    • First release
  • 23rd May, 2005
    • Removed unused member variable of CToolTipCtrl type from the CUIForm class
    • Removed unused string buffer for loading tooltip text in the CWmpHyperLinkImpl class' Init function
    • Fixed bug in EnableShutdownTokenPrivilege function - the second pointer parameter was referenced in the function body even if NULL was passed instead
    • Fixed bug in MuteSound function which always muted sound regardless of the user settings, and also changed it to return previous sound state (to restore later if needed)
    • Added new registry map macros
    • Replaced damaged setup executable


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior) SafeNet Inc
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

QuestionCan we enable or disable this plugin from another application Pin
Arun krishnan9-Sep-09 3:12
MemberArun krishnan9-Sep-09 3:12 
QuestionContact Pin
Dan_B22-Mar-09 4:04
MemberDan_B22-Mar-09 4:04 
QuestionPlay lists Pin
simpleandcleen15-Sep-07 17:32
Membersimpleandcleen15-Sep-07 17:32 
Questionhow Can I Add a Codec Pin
alaa_852-May-07 6:49
Memberalaa_852-May-07 6:49 
AnswerRe: how Can I Add a Codec Pin
Armen Hakobyan4-May-07 3:14
professionalArmen Hakobyan4-May-07 3:14 
AnswerRe: how Can I Add a Codec Pin
alaa_8511-May-07 5:26
Memberalaa_8511-May-07 5:26 
AnswerRe: how Can I Add a Codec Pin
Armen Hakobyan14-May-07 0:06
professionalArmen Hakobyan14-May-07 0:06 
QuestionMIDL definition Pin
docevil4-Mar-07 13:26
Memberdocevil4-Mar-07 13:26 
GeneralShared Data Segment Pin
John T24-Jul-06 7:08
MemberJohn T24-Jul-06 7:08 
GeneralRe: Shared Data Segment Pin
John T24-Jul-06 13:09
MemberJohn T24-Jul-06 13:09 
GeneralShow a dialog box Pin
dSolariuM18-Jul-06 4:59
MemberdSolariuM18-Jul-06 4:59 
JokeWMP10 WXP SP2 Pin
Absolom123424-Apr-06 1:51
MemberAbsolom123424-Apr-06 1:51 
QuestionCan you add A-B repeat function for WMP10? Pin
blueseye12-Apr-06 17:35
Memberblueseye12-Apr-06 17:35 
QuestionExternal Activation? Pin
blabla12221-Jan-06 3:11
Memberblabla12221-Jan-06 3:11 
GeneralMP 10 and Playlist Pin
Andi135722-Dec-05 13:17
MemberAndi135722-Dec-05 13:17 
Questionhow long for the timer Pin
a_m_p_098712-Sep-05 9:32
Membera_m_p_098712-Sep-05 9:32 
AnswerRe: how long for the timer Pin
Member 23228081-Oct-05 20:04
MemberMember 23228081-Oct-05 20:04 
GeneralRe: how long for the timer Pin
a_m_p_098710-Oct-05 9:30
Membera_m_p_098710-Oct-05 9:30 
GeneralRe: how long for the timer Pin
kekek12324-Mar-10 6:40
Memberkekek12324-Mar-10 6:40 
GeneralRe: how long for the timer Pin
John T24-Jul-06 12:46
MemberJohn T24-Jul-06 12:46 

The code as it is now doesn't set a timer to end playing, but
checks the state of the Media Player at a constant interval.
If the state is wmppsMediaEnded when you "set the timer",
the app sets the Standby Mode.

The article says in this context:
"Frankly speaking, I don't know if it really is a timer at all,
but no matter."

Hope this helps. Wink | ;)
GeneralRe: how long for the timer Pin
blsad3-Sep-09 23:28
Memberblsad3-Sep-09 23:28 
GeneralWMP 10 Pin
Ashutosh Bhawasinka24-May-05 12:34
MemberAshutosh Bhawasinka24-May-05 12:34 
GeneralRe: WMP 10 Pin
Armen Hakobyan25-May-05 1:25
professionalArmen Hakobyan25-May-05 1:25 
GeneralRe: WMP 10 Pin
kekek12324-Mar-10 6:34
Memberkekek12324-Mar-10 6:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.