使用JavaScript为Windows Media Player创建播放列表 [英] Creating a Playlist For Windows Media Player With JavaScript

查看:63
本文介绍了使用JavaScript为Windows Media Player创建播放列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究使用Windows Media Player播放电影的项目和

我用JavaScript控制一切。根据客户端我只需要

来支持IE 6或更高版本,这会让事情变得更容易。


我需要做的是创建一个播放列表并使用JavaScript播放它。我

继续接近但不够接近播放dang文件。有没有

之前有人这么做过,可以解释一下对他们有用的东西吗?

I''m working on project that plays movies using Windows Media Player and
I''m controlling everything with JavaScript. Per the client I only need
to support IE 6 or greater which happens to make things a bit easier.

What I need to do is create a playlist and play it using JavaScript. I
keep on getting close but not close enough to play the dang files. Has
anyone done this before and can shed some light on what worked for them?

推荐答案

" ;托尼" < t3 ******** @ gmail.comwrote in news:1163125520.444743.265720

@ k70g2000cwa.googlegroups.com:
"Tony" <t3********@gmail.comwrote in news:1163125520.444743.265720
@k70g2000cwa.googlegroups.com:

我正在研究使用Windows Media Player播放电影的项目和

我用JavaScript控制一切。根据客户端我只需要

来支持IE 6或更高版本,这会让事情变得更容易。


我需要做的是创建一个播放列表并使用JavaScript播放它。我

继续接近但不够接近播放dang文件。有没有

之前有人这么做过,可以说明什么适用于
I''m working on project that plays movies using Windows Media Player and
I''m controlling everything with JavaScript. Per the client I only need
to support IE 6 or greater which happens to make things a bit easier.

What I need to do is create a playlist and play it using JavaScript. I
keep on getting close but not close enough to play the dang files. Has
anyone done this before and can shed some light on what worked for



他们?

你有没有试过Googling(播放列表javascript和windows media player)?


最初的结果之一是:

" ASX-O-Matic是一个HTML / Javascript生成器用于ASX播放列表

与Windows Mediaplayer。

them?
Have you tried Googling (playlist javascript "windows media player") ?

One of the first results is:
"ASX-O-Matic is a HTML/Javascript generator for ASX playlists to be used
with Windows Mediaplayer."




Tony写道:

Tony wrote:

我正在研究使用Windows Media Player播放电影的项目和

我用JavaScript控制一切。根据客户端我只需要

来支持IE 6或更高版本,这会让事情变得更容易。


我需要做的是创建一个播放列表并使用JavaScript播放它。我

继续接近但不够接近播放dang文件。有没有

之前有人这么做过,可以说明对他们有用的东西吗?
I''m working on project that plays movies using Windows Media Player and
I''m controlling everything with JavaScript. Per the client I only need
to support IE 6 or greater which happens to make things a bit easier.

What I need to do is create a playlist and play it using JavaScript. I
keep on getting close but not close enough to play the dang files. Has
anyone done this before and can shed some light on what worked for them?



如果您的播放列表每次播放一段视频后按顺序播放

,那么您的工作将非常简单,你不需要

限制IE 6 +浏览器。


WMP将播放几种类型的视频,其中.wmv是最多的

普通。这可以使用wvx播放列表文件按顺序播放视频。

例如,下面的对象用于播放WMV:


< div style = " text-align:center">

< object data =" http://www.cwdjr.info/movie/cancanvbr.wvx"

type = QUOT;视频/ X-MS-WVX"风格= QUOT;宽度:400像素;身高:309px">

< param name =" src" value =" http://www.cwdjr.info/movie/cancanvbr.wvx"

valuetype =" ref" />

< param name =" showcontrols"值= QUOT 1 QUOT;值类型= QUOT;数据" />

< param name =" showstatusbar"值= QUOT 1 QUOT;值类型= QUOT;数据" />

< param name =" autostart"值= QUOT; 0"值类型= QUOT;数据" />

< param name =" volume"值= QUOT; 0"值类型= QUOT;数据" />

< param name =" PlayCount"值= QUOT 1 QUOT;值类型= QUOT;数据" />

< / object>

< / div>


注意这会使用.wvx播放列表文件。 .wvx文件具有XML

结构,如下所示:


< ASX VERSION =" 3.0">

< ENTRY>

< REF HREF =" http://www.cwdjr.info/movie/CanCanvbr.wmv" />

< / ENTRY>

< / ASX>


我只是放了一个视频,但是你可以使用

相同的entry-ref- / entry结构添加任意多个。该参考指向实际的.wmv视频文件的

位置。


现在,如果你想改变视频的顺序

播放(比如允许观众从几个视频中选择播放列表

选项)你有更多的问题。如果代码要验证并在大多数现代的b
浏览器上播放,那么使用脚本WMP并不容易控制

。但是,如果您只对IE浏览器感兴趣,那么您可能会在Microsoft开发人员网站上的某处找到有关编写脚本的信息 - 至少几年前它就在那里

a。我不会使用这样的代码,但很多人会这样做。


使用上述技术的工作页面示例是 nofollowhref =http://www.cwdjr.info/broadbandMedia/formatsOB/cancanWMV.php\"target =_ blank> http://www.cwdjr.info/broadbandMedia.../cancanWMV.php 。

页面专为宽带而设计,比特率约为2 Mbps。它可能会以低得多的价格运行,但是缓冲时间将会变得过多,直到下载足够的数据以允许流式启动

无需停在某处赶上装载。至少

播放器会指示缓冲的进度,以便您知道

视频正在下载。

If your playlist is to be the same every time with one video played
after the other in sequence, your job will be easy and you need not
limit to IE 6 + browsers.

The WMP will play a few types of videos, with .wmv being the most
common. This can use a wvx playlist file to play videos in sequence.
For example the below object is used to play the WMV:

<div style="text-align:center">
<object data="http://www.cwdjr.info/movie/cancanvbr.wvx"
type="video/x-ms-wvx" style="width:400px; height:309px">
<param name="src" value="http://www.cwdjr.info/movie/cancanvbr.wvx"
valuetype="ref" />
<param name="showcontrols" value="1" valuetype="data" />
<param name="showstatusbar" value="1" valuetype="data" />
<param name="autostart" value="0" valuetype="data" />
<param name="volume" value="0" valuetype="data" />
<param name="PlayCount" value="1" valuetype="data" />
</object>
</div>

Notice this uses the .wvx playlist file. A .wvx file has an XML
structure and looks like:

<ASX VERSION="3.0">
<ENTRY>
<REF HREF="http://www.cwdjr.info/movie/CanCanvbr.wmv" />
</ENTRY>
</ASX>

I just put in one video, but you can add as many as you wish using the
same entry-ref-/entry structure as above. The reference points to the
location of the actual .wmv video files.

Now if you want to change around the sequence in which the videos are
played(say allow the viewer to select a play list from several video
choices) you have more of a problem. The WMP is not easy to control
with script if the code is to validate and play on most modern
browsers. However, if you are interested in IE browsers only, as you
state, then you likely can find information concerning scripting the
WMP somewhere on the Microsoft developers site - at least it was there
a few years ago. I wiil not use such code, but many will.

An example of a working page that uses the above mentioned technique is
at http://www.cwdjr.info/broadbandMedia.../cancanWMV.php . The
page is designed for broadband with a bit rate of about 2 Mbps. It
likely will work at much lower rates, but the buffering time will then
become excessive until enough is downloaded to allow streaming to start
without having to stop somewhere to catch up with loading. At least the
player will indicate the progress of buffering so that you know the
video is downloading.

问题是我有一个菜单项列表,它有一个函数

附加到将加载该电影的onclick事件处理程序,或者

而不是播放它来自我创建的播放列表。所以假设我有一个

对象,其id为Player。那就是Windows Media Player。


我在微软MSDN网站的在线文档中读到了

如果我做了以下事情:


//创建一个电影片组数组。 .wmv是指.wmv。将在循环后附加



wmvs = new Array();

wmvs [0] =''theFirstMovie'';

wmvs [1] =''theSecondMovie'';


//循环播放wmv数组并将电影放入播放器中

播放列表

for(var index = 0; index< = wmvs.length; index ++)

{

wmvMovie = wmvs [index] +''。wmv'';

mediaItem = Player.newMedia(wmvMovie);

Player.currentPlayList.appendItem(mediaItem);

}


然后应该有效,然后我会使用

函数播放电影,该函数通过参数中的索引检索电影是

传入然后播放电影。


功能PlayMovie(movieIndex)

{

var movieToPlay = Player.currentPlayList.item(movieIndex);

Player.URL = movieToPlay.sourceURL;

//尝试下面的行而不是上面的行和它THR a一个漂亮的

奇怪的错误。

//Player.controls.playItem(movieToPlay);

}


这应该有效,但出于某种原因,它不是。我知道我必须离开

。我花了一天时间用谷歌搜索这个解决方案,而且我还没有真正发现任何接近它的东西。所以也许我最终可能会想到这一点,当我这样做时,我会把它发回到这个论坛,所以我们有了它b / b
记录。我之所以没有使用asx playist文件或其他什么

的原因是因为我需要播放一个特定的文件并且

然后从那个指数继续发挥作用。所以我很抱歉没有提供更多的背景资料。

The problem is that I have a list of menu items that have a function
attached to the onclick event handler that will load that movie, or
rather play it from the playlist that I created. So lets say I have an
object with the id of "Player" that is the Windows Media Player.

I read in the documentation online from Microsoft''s MSDN website that
if I went something to the effect of:

// Create an array of the movie titles. The ".wmv" will be appended
later when looping
wmvs = new Array();
wmvs[0] = ''theFirstMovie'';
wmvs[1] = ''theSecondMovie'';

// Loop through the wmv array and place the movie into the Player''s
playlist
for(var index = 0; index <= wmvs.length; index++)
{
wmvMovie = wmvs[index]+''.wmv'';
mediaItem = Player.newMedia(wmvMovie);
Player.currentPlayList.appendItem(mediaItem);
}

Then that should have worked and then I would play the movie using a
function that retrieves the movie by the index from the param that was
passed in and then play the movie.

function PlayMovie(movieIndex)
{
var movieToPlay = Player.currentPlayList.item(movieIndex);
Player.URL = movieToPlay.sourceURL;
//Tried the line below instead of the one above and it throws a pretty
weird error.
//Player.controls.playItem(movieToPlay);
}

That should work but for some reason it''s not. I know I gotta be off by
something. I have spent my day googling for this solution and I haven''t
really found anything close to it. So maybe I might eventually figure
this out and when I do I''ll post it back to this forum so we have it
documented. The reason I''m not using the asx playist file or whatever
it''s called is due to the fact that I need to play a specific file and
then continously play from that index onward. So I appologize for not
providing more of a background in the begining.


这篇关于使用JavaScript为Windows Media Player创建播放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆