1

我有一个脚本正在调用 youtube 提要,然后显示视频(无 iframe)请看一下小提琴:JsFiddle

我想在播放器顶部显示一个 img,所以我附加了一个这样的 img:

 html += '<span>Top Rated</span><img src="http://christianjamesphoto.com/themes/chrisjames/images/arrow-left.gif" /></div>';

并分配给它一个z-index:9999;但是这似乎不起作用。我已经搜索了这个问题的答案,似乎我必须wmode="transparent"输入链接,但我不确定如何在 url 中实现它。我该怎么做才能让它在播放器顶部显示 img?

4

2 回答 2

2

您可以像这样向 jTubeEmbed 插件添加一个新选项:http: //jsfiddle.net/aFx29/2/

变化:

    jTubeEmbed: function(video, options) {
        var options = $.extend({
            // Embed Options
            width: 560,
            height: 340,
            wmode: 'window', // can be window, transparent and opaque

            // Player Options
            autoplay: false,
            fullscreen: false,
            related: true,
            loop: false,
            keyboard: true,
            genie: false,
            border: false,
            highdef: true,
            start: 0
        }, options);

        // ... ommitted for brevity ...

        if(options.wmode) {
            videoEmbed += '<param name="wmode" value="' + options.wmode + '"></param>';
        }

        if(options.fullscreen == true) {
            videoEmbed += '<param name="allowFullScreen" value="true"></param>';
        }

        videoEmbed += '<embed src="'+videoUrl+'"';
        videoEmbed += '    type="application/x-shockwave-flash"';

        if(options.wmode) {
            videoEmbed += '    wmode="' + options.wmode + '"';
        }

        if(options.fullscreen == true) {
            videoEmbed += '    allowfullscreen="true"';
        }

        videoEmbed += '    allowscriptaccess="always"';
        videoEmbed += '    width="'+options.width+'" height="'+options.height+'">';
        videoEmbed += '    </embed>';
        videoEmbed += '</object>';

        return videoEmbed;
    }

并在调用时传递您想要的选项,jTubeEmbed例如:

$.jTubeEmbed(this.video, {
    // your options here,
    wmode: 'opaque'
});
于 2012-10-19T15:20:28.137 回答
0

播放器是一个 flash 对象,要将图像放在顶部,您应该考虑:

在 Flash 对象上方显示图像

将此参数添加到 videoEmbed:

videoEmbed += '<param name="wmode" value="transparent"></param>';

你可以在你的代码中尝试这样的事情:

html = '<li>';
html += '<div style="position:absolute; top:0px; z-index:2000;"><span>Top Rated</span>';
html += '<img src="http://christianjamesphoto.com/themes/chrisjames/images/arrow-left.gif" alt="" /></div>';
html += $.jTubeEmbed(this.video, embedOptions);
html += '<a href="'+this.link+'">'+this.title+'</a>';
html += '</li>';
于 2012-10-19T15:05:43.473 回答