如何使 soundcloud oembed endpoint return 成为高度为 300 的 iframe?

How to make soundcloud oembed endpoint return an iframe with a height of 300?

我用的是souncloud的oembed端点,默认高度是400,太大了。

我需要调整一下,我已经试过了:

https://soundcloud.com/oembed?format=json&height=300&url=https://soundcloud.com/giorgiomartini

但这只会改变艺术品的高度,请注意 html 键(iframe)末尾的高度,在 json 我回来了:

{
"version": 1,
"type": "rich",
"provider_name": "SoundCloud",
"provider_url": "http://soundcloud.com",
"height": 450,
"width": "100%",
"title": "Giorgio Martini",
"description": null,
"thumbnail_url": "http://i1.sndcdn.com/avatars-000336450748-qnkjy0-t500x500.jpg",
"html": "<iframe width=\"100%\" height=\"450\" scrolling=\"no\" frameborder=\"no\" src=\"https://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Fusers%2F1367858&show_artwork=true&height=300\"></iframe>",
"author_name": "Giorgio Martini",
"author_url": "https://soundcloud.com/giorgiomartini"
}

但是我确实需要更改 iframe 本身的高度...oembeed 有办法做到这一点吗?

或者我是否必须对返回的响应进行某种字符串操作以将高度从 400 更改为 300?

谢谢

根据 documentation,有一个名为 maxheight 的 URL 参数 - 只需将其设置为 300:

https://soundcloud.com/oembed?format=json&maxheight=300&url=https://soundcloud.com/giorgiomartini

我建议改用 CSS 以使视频 iframe 具有响应性,因此无论 window 在任何设备上的大小如何,它总是填满其父容器。请参阅 Fluid Width Video 和 VideoWrapper class。