Javascript API 不适用于 JW Player 5.9 上的 Chrome 或 Safari [英] Javascript API not working for Chrome or Safari on JW Player 5.9

查看:40
本文介绍了Javascript API 不适用于 JW Player 5.9 上的 Chrome 或 Safari的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 JW Player 开发一个自定义界面,该界面显示当前曲目标题并具有播放/暂停、下一首曲目、上一首曲目和音量切换按钮.

它适用于 IE8/9 和 FF,但不适用于 Chrome 和 Safari.Chrome 的控制台给出以下错误:Uncaught TypeError: Object # has no method 'addControllerListener'

这是我用于测试的代码.

<div id="container">加载播放器...</div><script type="text/javascript">jwplayer("容器").setup({图像:预览.jpg",高度:320,宽度:480,模式:[{类型:html5"},{ type: "flash", src: "player.swf" }],播放列表":[{ 'file': "audio/01.mp3", 'title': "Track 1" },{ 'file': "audio/02.mp3", 'title': "Track 2" },{ 'file': "audio/03.mp3", 'title': "Track 3" }],});函数 playerReady(obj){player = document.getElementById(obj.id);显示第一项();};函数显示第一项(){尝试{播放列表 = player.getPlaylist();}捕获(e){setTimeout("displayFirstItem()", 100);}player.addControllerListener('ITEM', 'itemMonitor');itemMonitor({index:0});};功能 itemMonitor(obj){$('#nowplaying').html('<span><strong>正在播放:</strong>' + playlist[obj.index]['title'] + '</span>');};<div id="nowplaying"></div><div class="control_bar"><ul><li onclick='player.sendEvent("play");'>[ &#8250;] 播放/暂停<li onclick='player.sendEvent("prev");'>[ &laquo;] 上一项<li onclick='player.sendEvent("next");'>[ &raquo;] 下一项

我已经搜索并尝试了一些修改,比如添加 javascriptid 参数,但似乎对 Chrome 或 Safari 没有任何作用.

有什么想法吗?谢谢

解决方案

简短

删除{ type: "html5" },.

HTML5 使用 divs 和 img 标签呈现播放器并播放您的视频,它不支持 Flash 版本支持的所有内容,包括部分 JS API.

I am working on a custom interface for the JW Player which displays the current track title and has play/pause, next track, previous track and volume toggle buttons.

It works for IE8/9 and FF but fails for Chrome and Safari. Chrome's console gives the following error: Uncaught TypeError: Object # has no method 'addControllerListener'

This is the code I am using for testing.

<div id="container">Loading the player ...</div>
<script type="text/javascript">
    jwplayer("container").setup({
        image: "preview.jpg",
        height: 320,
        width: 480,
        modes: [
            { type: "html5" },
            { type: "flash", src: "player.swf" }
        ],
        'playlist': [
            { 'file': "audio/01.mp3", 'title': "Track 1" },
            { 'file': "audio/02.mp3", 'title': "Track 2" },
            { 'file': "audio/03.mp3", 'title': "Track 3" }
        ],
    });

    function playerReady(obj)
    {
        player = document.getElementById(obj.id);
        displayFirstItem();
    };

    function displayFirstItem()
    {
        try
        {
            playlist = player.getPlaylist();
        }
        catch(e)
        { 
            setTimeout("displayFirstItem()", 100);
        }

        player.addControllerListener('ITEM', 'itemMonitor');
        itemMonitor({index:0});
    };

    function itemMonitor(obj)
    {
        $('#nowplaying').html('<span><strong>Now Playing:</strong> ' + playlist[obj.index]['title'] + '</span>');
    };
</script>
<div id="nowplaying"></div>
<div class="control_bar">
    <ul>
         <li onclick='player.sendEvent("play");'>[ &#8250; ] Play / Pause</li>
         <li onclick='player.sendEvent("prev");'>[ &laquo; ] Previous item</li>
         <li onclick='player.sendEvent("next");'>[ &raquo; ] Next item</li>
    </ul>
</div>

I have searched and tried several modifications, like adding the javascriptid parameter, nothing seems to work for Chrome or Safari.

Any ideas? Thanks

解决方案

Short

Remove { type: "html5" },.

Long

HTML5 renders the player with divs and img tags and plays your videos and it doesn't support everything the flash version supports, including parts of the JS API.

这篇关于Javascript API 不适用于 JW Player 5.9 上的 Chrome 或 Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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