How to change soundcloud's Visual Player to classic style player setting visual:false via Ruby

216 views Asked by At

I'm currently using the soundcloud gem and omembed endpoint however I am unable to change the player's visual=true to visual=false which results in getting the new styled visual player widget. Even when I add visual=false as an option I get visual=true and visual=false and it seems visual=true wins out since it is the first value returned in the url...Anyone fix this via the Ruby SDK?

1

There are 1 answers

0
bkunzi01 On

Figured it out. When setting the visual parameter to false in oembed you'll actually notice two visual params in your src url. The first will still be true and then the second will be what you called in oembed. Unfortunately this doesn't supercede the first visual=true setting. You'll need to use some jquery to alter the incoming url's visual parameter. Contrary to all documentation on the subject, this must not be set to false but must actually be removed completely...See below:

$(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', ' ')); } }); });

It's basically replacing the visual param with a blank space for any url's containing soundcloud.com/player...You can then use the omembed parameters in your controller as intended like show_artwork etc. once this is done.