首 页 教育新闻课件中心论文中心教学教案试题中心语文专题综合下载技术教程公务员  
设为首页
加入收藏
联系我们
您当前的位置:中国教育资源网 -> 技术教程 -> 网络相关 -> 服务器 -> Web服务器 -> 技术内容 退出登录 用户管理

关于WEB使用mediaplayer的一些说明Web服务器教程

论文作者:佚名  论文来源:不详  论文发布时间:2006-6-18 22:53:20  论文发布人:chjchjchj

减小字体 增大字体

              摘要:关于WEB使用mediaplayer的一些说明

Simple Example of Scripting in a Web Page


You can easily embed the Windows Media Player control in an HTML file using any scripting language your browser recognizes. The following simple example uses Microsoft JScript to create a page that will play a file when you click on a button, and stop playing the file when you click on another button.


You can embed the Windows Media Player ActiveX control in a Web page using the following four steps:


  1. Create the Web page.
  2. Add the OBJECT tag.
  3. Add a user interface. In this case, two buttons.
  4. Add a few lines of code to respond when the user clicks on one of the buttons you have created.

Creating the Web Page


The first step is to create a valid HTML Web page. The following code is the minimum needed to create a blank but valid HTML page:

<HTML>
<HEAD>
</HEAD>
<BODY>
</BODY>
</HTML>

Adding the OBJECT Tag


Once you have created a Web page, you need to add an OBJECT tag. This identifies the ActiveX control to the browser and sets up any initial definitions. You must place the OBJECT tag in the BODY of the code. If you place it in the BODY, the default user interface of Windows Media Player will be visible. If you want to create your own user interface, set the height and width attributes to 0 (zero). You can also set the Player.uiMode property to "invisible" when you want to hide the control, but still reserve space for it on the page. The following code is recommended when you provide a custom user interface:

<OBJECT ID="Player" height="0" width="0"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
</OBJECT>

The following OBJECT tag attributes are required:


ID


The name that will be used by other parts of the code to identify and use the ActiveX control. You can choose any name you want, as long as it is a name that is not already used by HTML, HTML extensions, or the scripting language you are using. In this example, the name Player is used, but you could also call it MyPlayer or something else. Just pick a name that is unique to that Web page.


CLASSID


A very large hexadecimal number that is unique to the control. Only one control has this number and it is the Windows Media Player ActiveX control. To prevent typographical errors, you can copy and paste this number from the documentation. Versions of the Windows Media Player control prior to version 7.0 had a different CLASSID.


Adding a User Interface


HTML allows a vast wealth of user interface elements, allowing the user to interact with your Web page by clicking, pressing keys, and other user actions. Adding a few INPUT buttons is the easiest way to provide a quick user interface. The following code creates two buttons that can respond to the user. Clicking one button starts the media stream playing and the other button stops it:

<INPUT TYPE="BUTTON" NAME="BtnPlay" VALUE="Play" OnClick="StartMeUp()">
<INPUT TYPE="BUTTON" NAME="BtnStop" VALUE="Stop" OnClick="ShutMeDown()">

The name of the button is used to identify the button to your code; the value is the label that will appear on the button, and the OnClick attribute identifies which part of your scripting code will be called when the button is clicked.


Adding Scripting Code


Scripting code adds interactivity to your page. Scripting code can respond to events, call methods, and change run-time properties. Extended scripts are enclosed in a SCRIPT tag set. The SCRIPT tag tells the browser where your scripting code is and identifies the scripting language. If you do not identify a language, the default language will be Microsoft JScript.


It is good authoring practice to enclose your script in HTML comment tags so browsers that do not support scripting do not render your code as text. Put the SCRIPT tag anywhere within the BODY of your HTML file and embed the comment-surrounded code within the opening and closing SCRIPT tags.


The following Microsoft JScript code example calls the Windows Media Player control and performs an appropriate action in response to the corresponding button click.

<SCRIPT>
<!--

function StartMeUp ()
{
Player.URL = "laure.wma";
}

function ShutMeDown ()
{
Player.controls.stop();
}

-->
</SCRIPT>

The example function, StartMeUp, is called when the button marked Play is clicked, and the ShutMeDown function is called when the Stop button is clicked.


The code inside StartMeUp uses the URL property to define a path to the media. The media will start playing immediately.


The ShutMeDown code calls the stop method of the Controls object. Note that the Controls object is called through the controls property of the Player object, which has the ID value of "Player".


The following code shows a complete example.

<HTML>
<HEAD>
</HEAD>
<BODY>
<OBJECT ID="Player" height="0" width="0"
CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">
</OBJECT>
<INPUT TYPE="BUTTON" NAME="BtnPlay" VALUE="Play" OnClick="StartMeUp()">
<INPUT TYPE="BUTTON" NAME="BtnStop" VALUE="Stop" OnClick="ShutMeDown()">
<SCRIPT>
<!--

function StartMeUp ()
{
Player.URL = "laure.wma";
}

function ShutMeDown ()
{
Player.controls.stop();
}

-->
</SCRIPT>
</BODY>
</HTML>

Note that you must provide a valid URL to a valid file name in the URL property. In this case the assumption is that the file laure.wma is in the same directory as the HTML file.

这个是从MSDN的SDK中copy的一段,不过说明了一些问题,比如说play和stop的问题,这个在WEB的ASP版常常看到的MEDIA PLAYER 的问题,这个很容易说明的用mediaid.controls.play()和media.control.stop();加以控制


Controls.currentItem


The currentItem property specifies or retrieves the current media item.


Syntax

player.controls.currentItem

Possible Values


This property is a read/write Media object.


Remarks


This method works only with items in Player.currentPlaylist. Calling currentItem with a reference to a saved media item is not supported.


Example Code


The following JScript example uses currentItem to set the player control current media item to the selected value in an HTML SELECT element. The current playlist was first specified by using PlaylistCollection.getByName. The Player object was created with ID = "Player".

<SELECT ID = playItem  NAME = "playItem"  LANGUAGE = "JScript"

/* Specify the current item when the selected list value changes. */
onChange = "Player.controls.currentItem = Player.currentPlaylist.item(playItem.value);">

/* Fill the SELECT element list with three items that match
the songs in the playl
[] [返回上一页] [打 印] [收 藏]  
 ∷相关技术评论  (评论内容只代表网友观点,与本站立场无关!) [查看发表评论...]
 
 中国教育资源网免费技术教程下载中心-站内广告 站内广告 中国教育资源网免费技术教程下载中心-站内广告 
 中国教育资源网站内搜索 站内搜索 中国教育资源网站内搜索 
 

   
 中国教育资源网免费技术教程下载中心-栏目导航 栏目导航 中国教育资源网免费技术教程下载中心-栏目导航 
· Windows 9XMEXP · Windows NT20002003
· LinuxBSD · 系统综合
· IISApache · 硬件技术
· Web服务器 · FTP服务器
· 邮件服务器 · 域名服务器
· Windows服务器 · 代理服务器
· 服务器综合
 
中国教育资源网免费技术教程下载中心-相关教程  相关技术 中国教育资源网免费技术教程下载中心-相关教程
· 对短信袋鼠资费情况
· 关于WEB服务器系统盘
 中国教育资源网免费技术教程下载中心-本月热门教程 本月热门 中国教育资源网免费技术教程下载中心-本月热门教程 
 
 中国教育资源网免费技术教程下载中心-本日热门论文 本日热门 中国教育资源网免费技术教程下载中心-本日热门论文 
 
关于本站 - 网站帮助 - 免费课件 - 美容 - 绿色软件 - 软件下载 - 广告合作 - 下载声明 - 友情连接 - 网站地图 - 网站留言
浙ICP备06010405号 Email:cnkjz@163.com 技术支持:名流设计
版权所有 Copyright© 2002-2004 名流