3

我有以下 .swf 播放器,我想向播放器对象添加更多控件,例如播放和暂停:

<object classid="player" width="780" height="420" codebase="[longurl]"
    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
    <param value="sameDomain" name="allowScriptAccess" />
    <param name="movie" value="/root/Desktop/test.swf" />
    <param name="quality" value="best" />
    <param value="true" name="controller" />
    <param name="play" value="true" />
    <param name="loop" value="true" />
    <param name="wmode" value="window" />
    <param name="scale" value="showall" />
    <param name="menu" value="true" />
    <param name="devicefont" value="false" />
    <param name="salign" value="" />
    <param name="flashvars" 
        value='config={"clip":{"url":"video.flv","autoPlay":false}}' />
    <param name="allowScriptAccess" value="sameDomain" />
</object>
4

1 回答 1

0

我不确定我们是否可以在控件中嵌入播放/暂停选项。

但是,我们可以为“播放/暂停”添加一个按钮,单击该按钮会调用一个 JavaScript 函数来为我们执行播放或暂停。

只需将 id="myVideo" 添加到您的对象标签。

<script>
function playPause(){
    if(document.getElementById('myVideo').paused){
        document.getElementById('myVideo').play();
    }
    else
    {document.getElementById('myVideo').pause();
    }
}
</script>

<button onclick="playPause()">PLAY/PAUSE</button>

<object id="myVideo" classid="player" width="780" height="420" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param value="sameDomain" name="allowScriptAccess" />
<param name="movie" value="/root/Desktop/test.swf" />
<param name="quality" value="best" />
<param value="true" name="controller" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="flashvars" value='config={"clip":    
{"url":"video.flv","autoPlay":false}}' />
<param name="allowScriptAccess" value="sameDomain" />
</object>
于 2013-02-22T21:27:57.090 回答