1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.5 Soundcloud BB Code

Discussion in 'XenForo Questions and Support' started by fattony69, Aug 21, 2015.

  1. fattony69

    fattony69 Well-Known Member

    I am trying to create a BB Code for Soundcloud and I ran into an issue. There are multiple embeds for similar things, but I am not sure whether or not they require separate BB Codes or rather just one using Regrex. I'll show it below.

    There are four types of links (at least that I am aware of):
    • Public link
    • Private link
    • Public Set
    • Private Set
    I want to make it so that you can post any and there will be no issue. Here is what the links and the embed code look like.

    Public link with embed
    Code:
    https://soundcloud.com/edmassassin/anonymous-controlled-demolition-original-mix-download-version/s-ueMHc
    Code:
    <iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/172358598%3Fsecret_token%3Ds-ueMHc&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false"></iframe>
    Private link with embed
    Code:
    https://soundcloud.com/edmassassin/anonymous-controlled-demolition-original-mix-free-download
    Code:
    <iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/172358416&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false"></iframe>
    Public set with embed
    Code:
    https://soundcloud.com/edmassassin/sets/martin-garrix-top-10
    Code:
    <iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/16832803&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false"></iframe>
    Private set with embed
    Code:
    https://soundcloud.com/edmassassin/sets/martin-garrix-top-10/s-0K24d
    Code:
    <iframe width="100%" height="450" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/playlists/16832803%3Fsecret_token%3Ds-0K24d&amp;color=ff5500&amp;auto_play=false&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false"></iframe>
    Thanks for the help!
     
  2. Mike

    Mike XenForo Developer Staff Member

    Based on the embed code, there isn't enough information in the URL to generate the embed code from it. You would likely need custom PHP callbacks to pick out the correct identifiers for the embed code from the page.

    At the least, the sets/playlists and the links/tracks would need to be separate media sites. With and without the identifier could be handled together, but you'd need custom PHP to generate the necessary output as well.
     
    fattony69 likes this.
  3. EQnoble

    EQnoble Well-Known Member

    You can do it in a single bbcode with an expression like this...
    Code:
    #(?P<id>soundcloud\.com/(([a-z0-9-_]+/[a-z0-9-_]+/[a-z0-9-_]+)|([a-z0-9-_]+/[a-z0-9-_]+))(/[a-z0-9-]+)?)#si
    ...but yes a callback to differentiate between the embed types is needed for a single bbcode.

    Unmaintained - SoundCloud BBcode Media Site
     
    CreationNation likes this.
  4. CreationNation

    CreationNation Active Member

    Thanks for that @EQnoble ! Just implemented and converted 7,000 old soundcloud links on my music site, whew!
     
  5. AndyB

    AndyB Well-Known Member

Share This Page