4

从昨天开始,我们在嵌入 soundcloud 播放器时遇到了问题。我们使用 Oembed 方法,但似乎并非所有参数都可以操作。所以我们现在得到了新的视觉播放器而不是旧的变体。

例如当我们使用:http ://soundcloud.com/oembed?format=xml&url=https://soundcloud.com/radionetherlands/el-toque-educacion-sexual-a-la&visual=false

您会看到 xml 中的 html 节点现在包含 2 倍的视觉参数

<oembed>
    <version type="float">1.0</version>
    <type>rich</type>
    <provider-name>SoundCloud</provider-name>
     <provider-url>http://soundcloud.com</provider-url>
     <height type="integer">400</height>
     <width>100%</width>
     <title>El Toque: Educacion sexual a la mexicana by Radio Netherlands</title>
    <description>"Cuando nos deje de dar verguenza que un niño nos pregunte de dónde vienen los bebés, podremos decir que estamos en buen camino en materia de educación sexual", decía una participante en el Noveno Congreso Mexicano de Educación Sexual y sexología FEMESS, realizado recientemente en Aguascalientes, México. Hasta allá se hizo presente El Toque, donde nuestra colega Mara Landa conversó, entre otros, con Marcela Martínez, la presidenta de la Federación Mexicana de Educación Sexual y Sexualidad FEMESS y Erem Dira, voluntaria del comité organizador del congreso. Producción Mara Landa. Presentación Alejandro Pintamalli.</description>
    <thumbnail-url>http://i1.sndcdn.com/artworks-000061844084-068ssp-t500x500.jpg?e30f094</thumbnail-url>
    <html><![CDATA[<iframe width="100%" height="400" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?visual=true&url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F118490723&show_artwork=true&visual=false"></iframe>]]></html>
    <author-name>Radio Netherlands</author-name>
    <author-url>http://soundcloud.com/radionetherlands</author-url>
</oembed>
4

3 回答 3

5

在 SoundCloud 向 oEmbed 添加选项之前,这是一个临时解决方法。如果他们没有将新的视觉播放器设为默认值,那会更好,因为它现在破坏了 oEmbed 的每个实例。希望他们更新 API,以便正式支持它。

无论如何,这是临时解决方法。在将 iframe 代码插入 DOM 之前,我们基本上只是从 iframe 代码中剥离了可视播放器选项。此代码将进入您的 oEmbed 回调。

if (oEmbed) $('#player').html(oEmbed.html.replace('visual=true&',''));

于 2014-02-06T00:16:55.067 回答
0

我终于找到了一个可靠的解决方法,可以使用一些 jquery 来做到这一点。需要注意的是,我必须通过将 visual=true 替换为 ' ' 来完全删除视觉设置,而不是按照建议将其设置为 false。这只会针对有关 soundcloud 的 iframe 调用。

$(document).ready(function(){
$("iframe").each(function() {
    var src = $(this).attr('src');
    if(src.indexOf('https://w.soundcloud.com/player/?') != -1 && src.indexOf('visual=true') != -1) {
        $(this).attr('src', src.replace('visual=true', ' '));
    }
});
});

编辑:使用上面的代码,您终于可以在您的 oembed 调用中使用 show_artwork 和视觉参数!

于 2015-06-09T21:47:40.273 回答
-1

有办法修改。有人在推特上问过 SoundCloud,此后被多次引用。

更改visual=truevisual=false和。show_artwork=true_ show_artwork=false那应该照顾它!

来源: https ://twitter.com/16kbit/status/430477602286239744

希望这可以帮助。

于 2014-09-23T02:55:09.883 回答