gpt4 book ai didi

javascript - 从嵌入式播放器捕获 SendPlayStateChangeEvents

转载 作者:行者123 更新时间:2023-11-28 08:27:04 24 4
gpt4 key购买 nike

我正在使用以下脚本嵌入媒体播放器:

<script type="text/javascript">
document.write('<OBJECT id="Player"');
document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
document.write(' width=210 height=60>');
document.write(' <PARAM name="Volume" value="100">');
document.write(' <PARAM NAME="SendPlayStateChangeEvents" VALUE="True">');
document.write(' <PARAM name="uiMode" value="full"></OBJECT>');
</script>

例如,当我停止播放器时,我试图捕获“SendPlayStateChangeEvents”:

<script type="text/javascript">
function getPlayState(){
var getit = document.getElementById("Player");
getit.settings.volume = 100;
alert(getit.PlayState);
}
</script>

“getPlayState() 函数不起作用...

如何使用 JavaScript 监控 PlayState?

(我使用的是 vs web dev 2010、windows 7、vb.net)

最佳答案

我终于明白了...

嵌入正确:

  <script type="text/javascript">
document.write('<OBJECT id="Player"');
document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
document.write(' width=210 height=60>');
document.write(' <PARAM name="Volume" value="100">');
document.write(' <PARAM NAME="SendPlayStateChangeEvents" VALUE="1">');
document.write(' <PARAM name="uiMode" value="full"></OBJECT>');
</script>

为了监视 SendPlayStateChangeEvents,您需要使用 setInterval(function() 在脚本中设置计时器。

   <script type="text/javascript">
function showPlayer() {
$('a.play').on("click", function (event) {
var t = event.clientY;
var l = event.clientX + 200;
$(Player).css("position", "fixed").css("top", t + "px").css("left", l + "px");
$(Player).show();
myVar = setInterval(function () { getPlayerStatus() }, 2000);
})
}
</script>

然后计时器将每两秒检查一次事件更改。在这种情况下,它会检查“停止”或“就绪”,然后停止计时器。

<script type="text/javascript">
function getPlayerStatus() {
var s = Player.PlayState;
if (s == 1 || s == 10) {
$(Player).hide();
setTimeout(myStopFunction(), 500);
};
}
function myStopFunction() {
clearInterval(myVar);
}
</script>

希望这些信息对某人有帮助......

关于javascript - 从嵌入式播放器捕获 SendPlayStateChangeEvents,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22286416/

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