【问题标题】:Video Wall Layout视频墙布局
【发布时间】:2021-12-09 02:32:59
【问题描述】:

给定一个stageW by stageH,以及N个(任意)大小的视频srcVideoW by srcVideoH,如何最好地布局视频以覆盖最大覆盖范围?视频可以放大或缩小,但应按比例(纵向或横向)缩放并保持高度匹配。

let VideoCount = $("#Stage").find('video').length;
let stageW = $("#Stage").outerWidth();
let stageH = $("#Stage").outerHeight();
$("#Stage").find('video').each(function() {
    var srcVideoW = this.videoWidth;
    var srcVideoH = this.videoHeight;

    var BestWidth = 0;
    var BestHeight = 0;

    // Magical Javascript goes here

    $(this).css("float", "left");
    $(this).css("display", "inline-block");
    $(this).css("width", BestWidth+"px");
    $(this).css("height", BestHeight+"px");
}

最可能的布局是:如果只有 1 个视频,它可能会占用舞台宽度和高度,如果 2 个并排,3 个也连续,大约 4 个,第一行最好两个,第二行两个……等等

【问题讨论】:

  • 问题是什么?
  • 计算 BestWidth 和 BestHeight
  • 更新包括我的问号“如何最好地布局视频以覆盖最大覆盖范围?”

标签: javascript video layout


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多