嵌入式播放器在远程浏览器中不起作用 [英] Embedded player does not work in remote browser

查看:157
本文介绍了嵌入式播放器在远程浏览器中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Web项目(jsp)中使用嵌入式wmv播放器来播放服务器上的* .avi文件.当我单击jsp中的链接时,它们工作正常,正在播放视频.

I am using embedded wmv player in my web project(jsp) to play *.avi files which are located on the server. When i click on the links in jsp they work fine, the video is being played.

但是,当我尝试在另一台机器上打开页面时,嵌入式播放器无法正常工作,而是从服务器下载文件.

But when i try to open the page on another machine, the embedded player does not work, instead its downloading the file from the server.

这是我使用的代码

<script type="text/javascript">
function play(media){
document.getElementById('mediaplayer').innerHTML=
'<object classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95"'
'type="application/x-oleobject" width="320" height="285">'
'<param name="showControls" value="false">'
'<param name="fileName" value="'media '">'
'<embed type="application/x-mplayer2" width="320" height="285"'
'showcontrols="false" src="'media '"><\/embed><\/object>'
}
</script>
<div id="mediaplayer"></div>
<ul id="menu">
<li><a onclick="play(this.href);return false" href="http://www.myurlname/afghan.avi">Source 1</a></li>
</ul>

在网络上找到了上述脚本,但找不到解决方案.

found the above script on the web, but couldnt find a solution for it.

推荐答案

函数追加播放器标记的方式似乎不正确.您应该串联所有这些字符串.您确实有一条错误消息,打开浏览器的控制台,您将看到此信息:

The way your function appends the player markup seems to be incorrect. You should be concatenating all those strings. You do have an error message, open the browser's console and you'll see this:

未捕获到的SyntaxError:意外令牌<

Uncaught SyntaxError: Unexpected token <

我已经在用您的代码弄弄了

I've seen this on this fiddle with your code

这是我在旧项目中使用的示例方法:

Here's a sample method that I used in an old project:

    // this requires jquery
    var MediaLink_Click = function (e) {

        var mp = document.getElementById('mediaPlayer');
        if ((null !== mp) && (undefined !== mp)) {
            if ((null != mp.contentDocument) && (undefined !== mp.contentDocument)) {
                $("object").each(function () {
                    this.contentDocument.controls.stop();
                });
            }
            $(mp).remove();
        }

        var oeTags = '<object id="mediaPlayer" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" width="640px" height="480px"'
                    + 'codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701"'
                    + 'standby="Loading Microsoft Windows Media Player components..."'
                    + 'type="application/x-oleobject">'
                    + '   <param name="autoStart" value="true"/>'
                    + '   <param name="url"       value="' + e.data.media_path + '" />'
                    + '   <param name="wmode"     value="transparent" />'
                    + '   <param name="uiMode"    value="full" />'
                    + '   <param name="loop"      value="false" />'
                    + '   <embed id       ="EmbedmediaPlayer"'
                    + '       type        ="application/x-mplayer2"'
                    + '       src         ="' + e.data.media_path + '"'
                    + '       width       ="640"'
                    + '       height      ="480">'
                    + '   </embed>'
                    + '</object>';
        $("#mediaplayer").html(oeTags); 
    }; 

请注意,我在每行之前用加号(+)将字符串连接在一起. 您可以像这样使用它:

Note that I'm concatenating the strings with a plus(+) sign before each line. and you can use it like this:

$("a").bind("click", { media_path: "path to your file goes here" }, MediaLink_Click);

尝试一下,让我知道您是否可以跑步.

Try this and let me know if you are able to run.

此小提琴显示它运行"正常(.avi文件不存在,因此不会播放,但会加载播放器和所有内容)

This fiddle shows it "kinda" working (the .avi file doesn't exist so it's not gonna play, but it loads the player and everything)

这篇关于嵌入式播放器在远程浏览器中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆