jQuery 更改视频播放器的大小

jQuery changing the size of Video players

本文关键字:播放器 视频 jQuery      更新时间:2023-09-26

詹姆斯在这里。我正在处理一个处理帖子的项目(实际上是两个项目都需要相同的代码),除了内容始终是用户屏幕的 100%,并使用 jquery 划分宽度以制作相同数量的列无论屏幕分辨率如何。但是,我在发布视频时遇到问题。如果有人能帮我写(或写,那会更有帮助)一个脚本,将默认的 500px 视频强制到帖子的宽度?我用来划分帖子的脚本如下。任何答案都会有所帮助。哦,我正在撞这个,因为它已经快一周了,而且我还没有收到工作脚本。

    var container = function(){
    var posts = $(document).width() - 40;
    var entry = (posts - 200) / 5;
    $("#posts").css("width", posts);
    $(".entry").css("width", entry);
    $("img.photo").css("width", entry - 22);
}
container();

我正在这样做的网站是 http://jamestestblog5.tumblr.com感谢任何可以帮助解决这个问题的人,这真的很困扰我!

Hiya 请在此处查看演示: http://jsfiddle.net/ytcAk/

您可以在单击"增长"按钮时读取逻辑。

从旧解决方案分叉。 :)(请让我知道这是否是您正在寻找的,如果不是,我将删除此帖子)

J查询代码

function increaseVideoSize() {
    var columnWidth = 450; // width of your content column - any
    var defaultVideoWidth = 400; // theme tag width - 400,500
    var increaseRatio = columnWidth/defaultVideoWidth;
    $(".video-post").each(function() {
        var iframe = $("iframe", this);
        if(iframe.length>0) {
            var currHeight = iframe.height();
            var newHeight = currHeight * increaseRatio;
            iframe.height(newHeight).width(columnWidth);
        } else {
            var object = $("object", this);
            var embed = $("embed", object);
            var currHeight = object.attr('height');
            var newHeight = currHeight * increaseRatio;
            object.width(columnWidth).attr('height', newHeight);
            embed.width(columnWidth).attr('height', newHeight);
        };
    });
};​