Windows Media Player JavaScript 控制 - 多个播放器问题
希望你能帮忙。
我的 ASP.net MVC3 应用程序中有一个屏幕,显示多个 WindowsMediaPlayer 对象。我的观点摘录:
<object id="audio" width="100%" height="65" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" name="mediaPlayer">
<param name="URL" value="/QualityAssurance/PlayRecording/<%: Model.CustomerOrder.Id.ToString() %>/<%: System.IO.Path.GetFileName(Model.RecordingFilename) %>"/>
<param name="SendPlayStateChangeEvents" value="true"/>
<param name="AutoStart" value="false"/>
<param name="PlayCount" value="1"/>
<param name="stretchtofit" value="true"/>
<param name="showstatusbar" value="true"/>
<param name="enablepositioncontrols" value="true"/>
<param name="showpositioncontrols" value="true"/>
<param name="enabletracker" value="true"/>
<param name="showcontrols" value="true"/>
<param name="showaudiocontrols" value="true"/>
<param name="enablecontextmenu" value="true"/>
</object>
屏幕上可能同时有几个这样的玩家。我需要创建一段 JavaScript 来停止所有这些媒体播放器的播放。我的代码目前如下所示:
<script type="text/javascript" language="javascript">
function stopAllMedia() {
var elements = document.getElementsByTagName("object");
var i = 0;
for (i = 0; i < elements.length; i++) {
stopMedia(document.getElementById(elements[i].id));
}
}
function stopMedia(mediaPlayer) {
var wmp = new Object();
wmp.wmv = mediaPlayer.object;
wmp.wmv.controls.stop();
}
</script>
此代码将成功停止第一个 WMP 对象的播放,但不会停止其他对象的播放。但是,如果我在 stopMedia 中放置一个alert(''),它会被调用多次(即页面上的每个 WMP 调用一次)。但由于某种原因,它不会控制其他对象。
你能帮忙吗?
谢谢,
西蒙。
hope you can help.
I have a screen in my ASP.net MVC3 application that displays several WindowsMediaPlayer objects. Excerpt from my view:
<object id="audio" width="100%" height="65" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" type="application/x-oleobject" name="mediaPlayer">
<param name="URL" value="/QualityAssurance/PlayRecording/<%: Model.CustomerOrder.Id.ToString() %>/<%: System.IO.Path.GetFileName(Model.RecordingFilename) %>"/>
<param name="SendPlayStateChangeEvents" value="true"/>
<param name="AutoStart" value="false"/>
<param name="PlayCount" value="1"/>
<param name="stretchtofit" value="true"/>
<param name="showstatusbar" value="true"/>
<param name="enablepositioncontrols" value="true"/>
<param name="showpositioncontrols" value="true"/>
<param name="enabletracker" value="true"/>
<param name="showcontrols" value="true"/>
<param name="showaudiocontrols" value="true"/>
<param name="enablecontextmenu" value="true"/>
</object>
There may be several of these players onscreen at any one time. I need to create a piece of JavaScript that stops playback of all of these media players. My code currently looks like this:
<script type="text/javascript" language="javascript">
function stopAllMedia() {
var elements = document.getElementsByTagName("object");
var i = 0;
for (i = 0; i < elements.length; i++) {
stopMedia(document.getElementById(elements[i].id));
}
}
function stopMedia(mediaPlayer) {
var wmp = new Object();
wmp.wmv = mediaPlayer.object;
wmp.wmv.controls.stop();
}
</script>
This code will successfully stop playback of the first WMP object, but not the others. However, if I put an alert('') inside stopMedia, it is getting called several times (i.e. once for each WMP on the page). But for some reason, it will just not control the other objects.
Can you help?
Thanks,
Simon.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试重写 {{{stopMedia}}} 函数?
我不确定这是否有效,但请尝试一下!
Did you try to rewrite the {{{stopMedia}}} function?
I am not sure if this is working, but have a try!