Controlling quicktime movie from javascript does not work in IE

為{幸葍}努か 提交于 2019-12-08 17:52:27

Ok, I think I figured it out. The trick is to use the ID from the <embed> element and not the <object> element. So the final (working) code I got is this.

HTML:

<div id="mkt-video" style="position:fixed;width:360px;background-color:black;padding:10px;border:solid 2px white;display:none;z-index:100003">
    <video id="video" width="360" height="298" controls="controls" autobuffer="autobuffer">
        <source src="/data/mmg-demo.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' />
        <source src="/data/mmg-demo.ogv" type="video/ogg" />
        <object classid='clsid:02bf25d5-8c17-4b23-bc80-d3488abddc6b' width="360" height="298" codebase='http://www.apple.com/qtactivex/qtplugin.cab' id="videoem-object">
            <param name='src' value="/data/mmg-demo.mp4" />
            <param name='autoplay' value="false" />
            <param name='controller' value="true" />
            <param name="enablejavascript" value="true" />
            <embed src="../files/380/380523/video.mp4" width="360" height="298" autoplay="false" controller="true" loop="false" pluginspage='http://www.apple.com/quicktime/download/' name="videoem" id="videoem"></embed>
        </object>
    </video>
</div>

And Javascript:

function closeVideo() {
    if(typeof document.getElementById('video').pause == 'function') {
        document.getElementById('video').pause();
    }
    try {
        document.getElementById('videoem-object').SetRate(0.0);
    }
    catch (err) {}
    $('#mkt-video').fadeOut();
}

The "try-catch" is required, because IE9 still creates the embed object but of some strange type and throws errors of some strange content. Anyway, it works fine now.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!