【问题标题】:JW Player not working in ChromeJW Player 无法在 Chrome 中运行
【发布时间】:2013-03-22 08:44:36
【问题描述】:

我在网站上使用 JW Player 播放 youtube 视频。我为此使用了嵌入代码。从我的本地目录执行文件时,它在所有浏览器中都能正常工作。但是从服务器执行文件时,它在谷歌浏览器中不起作用。下面是代码。

<embed id="ply" height="384" width="430" flashvars="autostart=true&repeat=always&file=http:/www.youtube.com/watch?v=cNBFihPwThM&screencolor=000000&backcolor=000000&frontcolor=ffffff&skin=http://www.creatingafamily.org/modules/mod_jwmedia/skins/snel.swf" wmode="transparent" allowscriptaccess="always" allowfullscreen="true" quality="high" bgcolor="#000000" name="ply" style="" src="http://www.creatingafamily.org/modules/mod_jwmedia/player.swf" type="application/x-shockwave-flash"/>

请帮助实现这一目标。提前致谢。

【问题讨论】:

    标签: php embed jwplayer


    【解决方案1】:

    首先,我们应该让jwplayer的javascript来构建html代码。

    用js初始化jwplayer,在html中使用HTML5视频如下:

    <center>            
        <video controls="controls" id="container" poster="http://www.example.com/yourvideothumbs/videothumb.jpg"  width="693" height="388">
                <source src="http://www.example.com/videos/jourvideo.mp4" type="video/mp4" />
        </video>                        
    </center>
    

    Javascript:

    if(navigator.userAgent.toLowerCase().match(/(android)/) || navigator.userAgent.toLowerCase().match(/(chrom)/) ){
        //wee must force flash video player in chrome, because mp4 video files is not supported yet in chrome's HTML5 video implementation.
        modes = [{type: 'flash', src:  '[JWPLAYERBASEDIR]/swf/player.swf'}];
    }else{
        modes = [ {type: 'html5'},{type: 'flash', src:  '[JWPLAYERBASEDIR]swf/player.swf'}];
    }
    
    jwplayer("container").setup({                   
        'modes':modes,      
    }); 
    

    这在所有浏览器中都有效。 jwplayer 是否支持 HTML5 可以符合。

    或以下强制实现 HTML4:

    <div id="container"></div>
    <script type="text/javascript">
        jwplayer("container").setup({
           modes = [{type: 'flash', src:  '[JWPLAYERBASEDIR]/swf/player.swf'}], //force flashplayer for video
           image: "yourvideothumbs/videothumb.jpg", //poster image
           file: "videos/jourvideo.mp4",  //video file 
           height: "693", //set height in px
           width: "388" //set width in px
       });
    

    在设置中你可以设置skincontrolsautostart任何你想要的: http://www.longtailvideo.com/support/jw-player/28839/embedding-the-player/

    【讨论】:

    • 我正在使用 HTML4。我需要在 HTML4 中做
    • 如果只使用这个,js 会将其转换为嵌入对象:modes = [{type: 'flash', src: '[JWPLAYERBASEDIR]/swf/player.swf'}] 用于模式。我也写了一个HTML4实现,强制使用flash播放器。
    • 我加了一个HTML4的例子来回答。
    • 我只将它用于服务器上的文件。对于 youtube 视频,我使用 youtube 的嵌入代码。我知道 youtube 不提供视频的直接访问,所以我不相信它可以很好地工作,但总有可能有一个有效的 hack :)
    • 上面发布的代码非常完美,它也适用于 YouTube 视频。
    猜你喜欢
    • 2012-11-22
    • 1970-01-01
    • 2013-07-25
    • 1970-01-01
    • 2014-02-05
    • 2012-08-28
    • 1970-01-01
    • 1970-01-01
    • 2018-10-25
    相关资源
    最近更新 更多