Vous êtes sur la page 1sur 3

JANUARY TUTOR ■

SKINNING WINDOWS

skinned
windows
Why settle for the dull default of Windows Media Player when you can create your own
funky look? Re-skin the ultra-conservative player with any type of style that you want.
In this month’s PC Tutor we tell you how you can begin to go about it – and then leave
you to your imagination...

ersion 7 of Microsoft Windows Windows Media Player\Skins). Every skin behaviour of the skin using very simple

V Media Player improves on earli-


er versions in a number of areas,
but the most intriguing new fea-
contains a Skin Definition File – a text file
with the extension WMS; most con-
tain a number of art files (BMP,
XML code. With this handful of rules, you’ll
know enough XML to start build-
ing skins:
ture is certainly its support for skins – com- GIF, JPG or PNG files) as well. • XML elements are defined
plete replacements for the program’s user A skin may also contain one using tags, similar to HTML
interface. You don’t need a degree in rock- or more JScript files. tags.
et science to create a skin, just a little The skin files for • Every open tag
patience and the ability to follow instruc- t hi s a r t ic l e a r e (such as <theme>)
tions. In this article, we’ll build a skin step available at www must have a close
by step. Once you know how, you can . p c m a g . c o m / s o l u- tag (</theme>).
devise a skin to reflect your personal inter- tions. Click the Solu- • Elements defined
ests or make a branded skin as a giveaway tions archive link between the open
for your media related Web site. next to the title and and close tags are
Start by downloading WMP 7 from www download the contained in the outer
. m i c rosoft.com/windowsmedia if you Skins.zip file. Place the element.
haven’t already done so. The player comes WMZ files in your Skins • An element that con-
with several sample skins, and you can folder so you can try them as tains no others can use an
download more from the same site. we go. open/close tag (for example
<player/>).
GETTING UNDER THE SKIN XML PRE-PRIMER • Tags are case sensitive, so
Each skin is defined by a WMZ file, which Microsoft has committed to ever stick with all caps or all lower-
is nothing but a ZIP archive, and installing increasing support for XML (eXten- case.
a skin is as simple as copying it to the sible Markup Language), and the Skin • Attributes modify elements and are
Skins folder (usually C:\Program Files\ Definition File defines the appearance and defined by name=”value” strings in the

90 January 2001 www.DITnet.co.ae ■ www.PCmag-mideast.com


■ JANUARY TUTOR
SKINNING WINDOWS

open tag.
A bare minimum skin consists of a theme
element containing a view element. Adding
a couple of attributes to the theme yields
the WMS file for the PCMAG_A skin:

<!— A minimal skin —>


<theme
title=”pcmag A”
author=”Neil J.Rubenking”>
<view>
</view> Figure 1: Start a new skin by creating seven button
</theme> images and a mapping image.

Launch WMP 7, highlight the PCMAG_A


skin in the Skin Chooser, then click Apply
Skin to see a fully functional (but boring)
skin that looks like a plain window. Figure 3: A visualization subview animates images
The skin’s shape is defined using a back- based on the music you’re playing.
ground image, with one particular colour
treated as transparent. Areas drawn with
the transparent colour are omitted from
the skin. Start with a 640x480-pixel image
and consider reserving an area about
240x180 pixels for video and special
effects. The image in the PCMAG_B skin
is a simple, rounded rectangle with a
r ound ed r ectangular cu tout and i t’s
installed using the following view ele-
ment’s attributes:

<view Figure 2: Then add a progress bar and track title Figure 4: Finally, you can add slide-out panels for
backgroundColor=”none” information. playlist and equaliser controls.
backgroundImage=”pcmag.bmp”
transparencyColor=”#00FF00” hovering over them, perhaps by bright- <playelement mappingColor=”#808000”/>
titleBar=”false” ening the colours or adding a glow, then <nextelement mappingColor=”#00FFFF”/>
resizeable=”false”> save it as b_hover.bmp. Finally, take the <ffwdelement mapping Color=”#FF00FF”/>
hover image, offset its contents to the right <stopelement mappingColor=”#800000”/>
The transparency colour is a hexadeci- and down by one or two pixels and save < p a u s e
e l e m e nmt a p p i n Cgo l o r =
mal number, with two digits apiece for it as b_down.bmp. Of course you can use ”#008000”/>
red, green and blue. In this case, the num- other filenames if you prefer. </buttongroup>
ber re p resents bright green. Load the The mapping image consists of blobs of
PCMAG_B skin to see the result. It does- solid colour that define the areas occu- The left and top attributes locate the but-
n’t do anything, but you can right click for pied by button elements. The colour blobs tongroup within the view. Setting cursor to
menu options and drag the skin around the should be just big enough to cover the hand makes the cursor change into a hand
desktop. corresponding button in all of the other when over a button. Each standard button
images. Because the colour blobs aren’t vis- has a pre-defined element type; all that’s
BUTTONING UP ible, you’ll normally use simple primary needed is a mappingColor that matches
Every skin needs some or all of the stan- colours. Figure 1 shows the main and map- the button’s colour within the mapping
dard buttons (Rewind, Previous Item, Play, ping images used in our sample skins. To image. The sample skin PCMAG_C has
Next Item, Fast Forward, Stop and Pause). enable the group of buttons, insert a but- seven fully functional buttons.
The buttons need not be rectangular; their tongroup element within the view element
appearance is defined by five images. Four like this: LISTENING ATTRIBUTES
are pictures of the button panel in differ- Attribute values don’t have to be static
ent states and the fifth maps regions of <buttongroup things like co-ordinates and bitmap names.
the button image to button elements. left=”152” top=”20” You can create dynamic attributes that
First create a picture of the seven buttons image=”b_image.bmp” automatically change to match values with-
and save it as b_image.bmp. Now modify disabledImage=”b_disabl.bmp” in the WMP itself. These are called listen-
the image so it represents disabled but- hoverImage=”b_hover.bmp” ing attributes, and they require the wmp-
tons, perhaps by changing the colours to downImage=”b_down.bmp” prop keyword. Inserting the following pro-
grey or drawing big red Xs through them, mappingImage=”b_map.bmp” g r e ss b a r e l e m e n t j us t af te r t h e
and save that as b_disabled.bmp. Load the cursor=”hand”> </buttongroup> close tag adds a bar that
original image and modify it to represent <rewelement mappingColor=”#FF0000”/>tracks how much of the current clip has
the buttons when the mouse pointer is <prevelement mapping Color=”#FFFF00”/> played.

www.DITnet.co.ae ■ www.PCmag-mideast.com January 2001 91


JANUARY TUTOR ■
SKINNING WINDOWS

<progressbar left=”194” top=”346” width=”240” visible=”true”/>


id=”myprogress” foregroundColor=”white” </subview>
l e f t = ” 2 1 4 ” t o p = ” 1 3 7 ” w i d t hfontSize=”11”
=”216”
height=”10” fontFace=”Arial” As its name suggests, a subview repre-
thumbImage=”thumb.bmp” scrolling=”true” sents a portion of a view. Setting its zIndex
transparencyColor=”#00FF00” value=”wmpprop:player.currentMedia.name” attribute to 1 makes the subview appear in
bordersize=”5” /> front of the main view (a negative zIndex
tooltip=”Current position” would put it behind the main view). The
backgroundColor=”purple” The second text element’s value is tied to clippingImage and clippingColor attribut-
foregroundcolor=”maroon” the name of the current media item using es limit the visible area of the subview and
cursor=”hand” wmpprop. Setting its scrolling attribute to the elements it contains. Adding support for
min=”0” true causes the item name to scroll hori- visualisations is as simple as inserting an
max=”wmpprop:player.currentMedia.dura zontally. Load the PCMAG_D.WMZ skin to effects element within the subview. The
tion” windowed attribute must be set to false so
value=”wmpprop:player.Controls.current that the effects element will be affected
Position” by the clippingColor.
onmouseup=”player.controls.currentPo- We’ll add a pair of buttons to step
sition=myprogress.value;”/> through the available visualisations
using a buttongroup with custom
The id attribute lets you refer- buttons, rather than built-ins. The
ence this element by name. complete definition of this but-
ThumbImage defines the mov- t o n g r o u p i s fo u n d i n
ing part of the progress bar – in PCMAG_E.WMZ; here’s the
this case, a 10x10 red circle. code for one button:
The bordersize attribute is set to
half the thumb’s width, other- <buttonelement
wise the thumb would be cut off id=”BtnNextVis”
at the start and end. Other attribut- mapping color = ”#0000FF”
es define the position, colour, cursor upToolTip=”Next visualization”
and ToolTip for the progress bar. onClick=”vis.next();”
The max attribute specifies the enabled=”wmpprop:vis.visible”/>
range of the progress bar, and it’s tied
to the duration of the current media The instruction defined by the
clip using the wmpprop keyword. onClick attribute’s value is exe-
The value attribute specifies the cu ted wh en the bu tto n is
thumb’s position, which follows c l i ck ed . In t his ca se , t he
the play position within the cur- i nstr u ct i on c all s th e nex t
rent clip. Without any actual pro- method of the effects element,
g r a mm in g , w e n o w h av e a which we named vis. The but-
p ro g ress bar that tracks WMP 7’s ton is only enabled when the
progress! see the skin with buttons, progress bar, and effects element is visible. Figure 3 shows the
The onmouseup attribute is something “Now playing:” text (Figure 2). result.
new: an event type attribute. This event
occurs when the mouse is clicked on the SPECIAL EFFECTS MORE ON THE WEB
element, possibly dragged, and then WMP 7 supports a feature called visualisa- Space constraints prevent us from includ-
released. At that time, the instruction in the tions – images that move and change in ing sections on adding video elements to
attribute’s value is executed. In this case, it direct relationship to the frequency spec- the code and on enhancing the skin by
sets WMP 7’s current position to the thumb’s trum and waveform of the current audio adding slide-out panels for the playlist and
position. This means the user can grab the output. Visualisations are displayed with- volume controls, as shown in Figure 4.
thumb with the mouse and skip ahead or in an effects element, which we’ll place These two sections are contained in the
back within the current media item. inside a subview element, like this: file Skins.rtf, which we’ve included in the
The following lines, inserted after the pro- Skins.zip file. The complete code for the
gressbar element, define a simple static text <subview skin is a lso in th e zi p f ile, saved as
element and a text element whose value zIndex=”1” PCMAG_H.
tracks the name of the current clip. left=”202” top=”146” You’ve got enough information now to
backgroundColor=”none” start creating skins of your own, but we’ve
<text backgroundImage=”mouthc.bmp” barely scratched the surface. The Windows
left=”194” top=”334” clippingImage=”mouthc.bmp” Media Player SDK (downloadable from
foregroundColor=”white” clippingColor=”#FFFFFF”> http://msdn.microsoft.com/windowsme-
fontSize=”8” <effects dia) defines all the elements, attributes and
fontFace=”Arial” id=”vis” objects used in creating WMP skins. And of
value=”Now playing:” l e f t = ” 0t ”o p = ” 0 w
” i d t h = ” 2 4 course,
0 ” you can open up any skin using
justification=”right”/> height=”180” your ZIP utility, extract its contents and
<text windowed=”false” study them to get ideas.

92 January 2001 www.DITnet.co.ae ■ www.PCmag-mideast.com

Vous aimerez peut-être aussi