gpt4 book ai didi

javascript - Windows Media Player 是否有文档化的 JavaScript API?

转载 作者:数据小太阳 更新时间:2023-10-29 04:24:59 25 4
gpt4 key购买 nike

我想使用 JavaScript 来控制嵌入式 Windows Media Player,以及访问播放器公开的任何属性。我在网上找到了一些骇人听闻的例子,但没有什么具体的。

我确实需要播放、暂停、停止、搜索、全屏等的访问权限。我还想访问播放器碰巧播放的任何事件。

帮助会很棒(我已经有一个 Flash equiv,你知道的),谢谢!

最佳答案

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>

关于javascript - Windows Media Player 是否有文档化的 JavaScript API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/299582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com