【问题标题】:Not able to change Oembed visual parameter无法更改 Oembed 视觉参数
【发布时间】:2014-01-29 21:34:00
【问题描述】:

从昨天开始,我们在嵌入 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>

【问题讨论】:

    标签: soundcloud oembed


    【解决方案1】:

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

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

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

    【讨论】:

    • 嘿@Joe,你能找到更好的解决方案吗?好像我也需要一样。
    • 哇,它已经一年多了,我仍然遇到这个问题......?!我的控制台中的某个 Soundcloud 库文件出现可疑错误。 “未捕获的 IndexSizeError:无法在 'CanvasRenderingContext2D' 上执行 'getImageData':源宽度为 0。”存档:w.soundcloud.com/player/assets/layouts/…
    【解决方案2】:

    我终于找到了一个可靠的解决方法,可以使用一些 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 和视觉参数!

    【讨论】:

      【解决方案3】:

      有一种方法可以修改。有人在推特上问过SoundCloud,此后被多次引用。

      visual=true 更改为visual=false 并将show_artwork=true 更改为show_artwork=false。那应该照顾它!

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

      希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 2014-08-15
        • 2022-08-03
        • 2011-08-29
        • 2019-08-05
        • 1970-01-01
        • 1970-01-01
        • 2017-01-12
        • 2013-03-19
        • 1970-01-01
        相关资源
        最近更新 更多