加载PDF时如何自动播放声音?

时间:2012-09-13 15:14:05

标签: javascript pdf audio acrobat

对于研究项目,我们需要在加载和显示PDF时自动播放声音。按照网络上的说明,我在Acrobat 9中编辑了PDF的JavaScript,如下所示:

/-------------------------------------------------------------
//-----------------Do not edit the XML tags--------------------
//-------------------------------------------------------------

//<Document-Level>
//<ACRO_source>init</ACRO_source>
//<ACRO_script>
/*********** belongs to: Document-Level:init ***********/
var bOpened;

function init()
{

    if(bOpened == "true")
    {
        // document already been opened
    }
    else
    {
        bOpened = "true";
        rm = this.getAnnotsRichMedia(this.pageNum)[0];
        if (!rm.activated)
            rm.activated=true;

        //The following alert works fine for the embedded mp3 and shows "[object AnnotRichMedia]"
        //app.alert(rm);
        rm.callAS("multimedia_volume", 0.75);
        rm.callAS("multimedia_play");
   }
}

// call init
init();
//</ACRO_script>
//</Document-Level>

我在PDF上拖动了一个音频控件来完成这项工作。控件的属性设置为:

  • 启用时间:打开包含内容的页面
  • 禁用时间:包含内容的页面已关闭
  • 播放风格:在页面上播放内容

上面的app.alert工作正常,并且有关嵌入式mp3对象的警报,表明它已被嵌入好了。我也可以使用屏幕上的控件播放mp3文件,表明编解码器等没有问题。但是,文档加载时听不到声音。

我在这里错过了什么吗?

0 个答案:

没有答案