分享

在firefox上用javascript控制windows media player 和 real player的播放

 Ralf_Jones 2007-12-13

控制real player的播放

播放页面:fx.html

代码:

<HTML>
<HEAD>
<TITLE>control realplayer with javascript in firefox</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--

// Test the playback status

function isPlaying() {
        if(document.javademo.CanPlay()) {
                alert("The player is currently paused or stopped.")
        }
        else {
                alert("The player is currently playing.")
        }
}

function isPaused() {
        if(document.javademo.CanPause()) {
                alert("The player is currently playing.")
        }
        else {
                alert("The player is currently paused or stopped.")
        }
}

function isStopped() {
        if(document.javademo.CanStop()) {
                alert("The player is currently playing or paused.")
        }
        else {
                alert("The player is currently stopped.")
        }
}

// -->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white">
<embed id="javademo" autogotourl=false type="
audio/x-pn-realaudio-plugin" src="fx.php" CONTROLS=ImageWindow width=320 height=240 border=0 autostart=true loop=true></embed>
<FORM>
<P><INPUT TYPE="button" VALUE="Play"
        onClick="document.javademo.DoPlay()">
<INPUT TYPE="button" VALUE="Pause"
 onClick="document.javademo.DoPause()">
<INPUT TYPE="button" VALUE="Stop"
        onClick="document.javademo.DoStop()"></P>
<P><INPUT TYPE="button" VALUE="Playing?"
        onClick="isPlaying()">
<INPUT TYPE="button" VALUE="Paused?"
        onClick="isPaused()">
<INPUT TYPE="button" VALUE="Stopped?"
        onClick="isStopped()"></P>

</FORM>
</BODY>
</HTML>

fx.php代码:

<?php

header("Content-type: application/vnd.rn-realmedia-vbr");
readfile("video/yc.rmvb");

?>

 
需要注意的地方:
1. 从firefox的官方文档里看标签embed的type应该是“application/vnd.rn-realplayer-javascript”的,但firefox竟然识别不了,改为"audio/x-pn-realaudio-plugin"就行了,视频当作音频用,但也能显示视频,不知道为什么会这样。
2.要正确输出视频文件的mime-type, rmvb的mime不是“video/vnd.rn-realvideo”,而是“application/vnd.rn-realmedia-vbr”
 
参考资料:
http://plugindoc./winmime.html   firefox支持的所有plugin 的mime type
http://service./help/library/guides/extend/embed.htm  real player的所有支持javascript调用的属性以及方法说明(官方英文)
http://blog.csdn.net/hzf100/archive/2007/08/15/1745198.aspx  real player的所有支持javascript调用的属性以及方法说明(中文)
 
控制windows media player 播放
mozilla官方实例:http://plugindoc./testpages/wmp11.html
注意的地方:
type="application/x-ms-wmp" ,这个表示用的是wmp11,如果firefox发现客户端是wmp9以下的话会提示安装一个微软的插件,安装完后就可以用javascript控制了。
而“application/x-mplayer2”表示调用的是wmp9,用这个type是不能用javascript来控制的。
 
参考资料:
http://msdn2.microsoft.com/en-us/library/bb614515.aspx  微软wmp11的msdn(Using the Windows Media Player Control with Firefox)
http://www./experiments/wmp_play.html  firefox下用flash控制wmplayer的例子

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多