Category Archives: Uncategorized

Creating a Playlist For Windows Media Player With JavaScript

<div>
<div style="margin: 5px 0px 0px 0px; padding: 0px; color: #1753AC; font-size: 95%; font-weight: bold;">
Creating a Playlist For Windows Media Player With JavaScript</div>
<div id="post_message_2193236" style="font-size: 105%; margin: 15px 0px 0px 0px; line-height: 20px; word-wrap: break-word;">
<br />
Tony wrote:
<div style="margin:20px; margin-top:5px; border-left: 2px #ccc solid; padding-left: 10px; font-size: 90%; color: #666; line-height: 18px; ">
I'm working on project that plays movies using Windows Media Player 
and<br />
I'm controlling everything with JavaScript. Per the client I only 
need<br />
to support IE 6 or greater which happens to make things a bit 
easier.<br />
&gt;<br />
What I need to do is create a playlist and play it using JavaScript. 
I<br />
keep on getting close but not close enough to play the dang files. 
Has<br />
anyone done this before and can shed some light on what worked for 
them? </div>
If your playlist is to be the same every time with one video played<br />
after the other in sequence, your job will be easy and you need not<br />
limit to IE 6 + browsers.<br />
<br />
The WMP will play a few types of videos, with .wmv being the most<br />
common. This can use a wvx playlist file to play videos in sequence.<br />
For example the below object is used to play the WMV:<br />
<br />
&lt;div style="text-align:center"&gt;<br />
&lt;object data="http://www.cwdjr.info/movie/cancanvbr.wvx"<br />
type="video/x-ms-wvx" style="width:400px; height:309px"&gt;<br />
&lt;param name="src" value="http://www.cwdjr.info/movie/cancanvbr.wvx"<br />
valuetype="ref" /&gt;<br />
&lt;param name="showcontrols" value="1" valuetype="data" /&gt;<br />
&lt;param name="showstatusbar" value="1" valuetype="data" /&gt;<br />
&lt;param name="autostart" value="0" valuetype="data" /&gt;<br />
&lt;param name="volume" value="0" valuetype="data" /&gt;<br />
&lt;param name="PlayCount" value="1" valuetype="data" /&gt;<br />
&lt;/object&gt;<br />
&lt;/div&gt;<br />
<br />
Notice this uses the .wvx playlist file. A .wvx file has an XML<br />
structure and looks like:<br />
<br />
&lt;ASX VERSION="3.0"&gt;<br />
&lt;ENTRY&gt;<br />
&lt;REF HREF="http://www.cwdjr.info/movie/CanCanvbr.wmv" /&gt;<br />
&lt;/ENTRY&gt;<br />
&lt;/ASX&gt;<br />
<br />
I just put in one video, but you can add as many as you wish using the<br />
same entry-ref-/entry structure as above. The reference points to the<br />
location of the actual .wmv video files.<br />
<br />
Now if you want to change around the sequence in which the videos are<br />
played(say allow the viewer to select a play list from several video<br />
choices) you have more of a problem. The WMP is not easy to control<br />
with script if the code is to validate and play on most modern<br />
browsers. However, if you are interested in IE browsers only, as you<br />
state, then you likely can find information concerning scripting the<br />
WMP somewhere on the Microsoft developers site - at least it was there<br />
a few years ago. I wiil not use such code, but many will.<br />
<br />
An example of a working page that uses the above mentioned technique is<br />
at
<a href="http://www.cwdjr.info/broadbandMedia/formatsOB/cancanWMV.php" rel="nofollow" target="_blank">
http://www.cwdjr.info/broadbandMedia.../cancanWMV.php</a> . The<br />
page is designed for broadband with a bit rate of about 2 Mbps. It<br />
likely will work at much lower rates, but the buffering time will then<br />
become excessive until enough is downloaded to allow streaming to start<br />
without having to stop somewhere to catch up with loading. At least the<br />
player will indicate the progress of buffering so that you know the<br />
video is downloading.<br />
</div>
%d bloggers like this: