是否有针对Windows Media Player的文档化JavaScript API?
发布时间:2020-12-13 20:47:46 所属栏目:Windows 来源:网络整理
导读:我想使用JavaScript来控制嵌入式Windows Media Player,以及访问播放器公开的任何属性.我在网上找到了一些hacky示例,但没有具体的内容. 我真的需要访问播放,暂停,停止,搜索,全屏等.我还想访问播放器正在播放的任何事件. 帮助会非常棒(我已经有了Flash等效,只
|
我想使用JavaScript来控制嵌入式Windows Media Player,以及访问播放器公开的任何属性.我在网上找到了一些hacky示例,但没有具体的内容.
我真的需要访问播放,暂停,停止,搜索,全屏等.我还想访问播放器正在播放的任何事件. 帮助会非常棒(我已经有了Flash等效,只有你知道),谢谢!
API需要Internet Explorer本机的ActiveX连接,或者可以使用
plugin for Firefox.
这是一个可以帮助您入门的示例页面. <html>
<head>
<title>so-wmp</title>
<script>
onload=function() {
player = document.getElementById("wmp");
player.URL = "test.mp3";
};
function add(text) {
document.body
.appendChild(document.createElement("div"))
.appendChild(document.createTextNode(text));
};
function handler(type) {
var a = arguments;
add(type +" = "+ PlayStates[a[1]]);
};
// http://msdn.microsoft.com/en-us/library/bb249361(VS.85).aspx
var PlayStates = {
0: "Undefined",// Windows Media Player is in an undefined state.
1: "Stopped",// Playback of the current media item is stopped.
2: "Paused",// Playback of the current media item is paused. When a media item is paused,resuming playback begins from the same location.
3: "Playing",// The current media item is playing.
4: "ScanForward",// The current media item is fast forwarding.
5: "ScanReverse",// The current media item is fast rewinding.
6: "Buffering",// The current media item is getting additional data from the server.
7: "Waiting",// Connection is established,but the server is not sending data. Waiting for session to begin.
8: "MediaEnded",// Media item has completed playback.
9: "Transitioning",// Preparing new media item.
10: "Ready",// Ready to begin playing.
11: "Reconnecting" // Reconnecting to stream.
};
</script>
<script for="wmp" event="PlayStateChange(newState)">
// http://msdn.microsoft.com/en-us/library/bb249362(VS.85).aspx
handler.call(this,"playstatechange",newState);
</script>
</head>
<body>
<div id="page">
<object id="wmp"
classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"
type="application/x-oleobject">
</object>
</div>
</body>
</html>
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- windows-server-2012-r2 – 应用dotdefender ISA
- window系统下的pycharm对虚拟机中的Ubuntu系统操
- windows – 这是什么原因“无法打开perl脚本:没
- 首次托管服务器经验完全手册
- Windows API一日一练 56 SetEndOfFile和GetFileS
- DirectX11 With Windows SDK--23 立方体映射:动
- 如何将MSI文件添加到我的安装程序
- 利用windows api共享内存通讯
- Windows Server 2012 R2 IIS 10 / HTTP / 2
- 为什么这个增加uint8_t的代码包括`&0xFF`?
热点阅读
