Last active
May 28, 2019 06:59
-
-
Save stigok/9e79e92c6b8144cf0a275092a6dd2777 to your computer and use it in GitHub Desktop.
Angular.js SoundCloud player widget directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('ngApp') | |
.directive('soundCloudPlayer', function () { | |
return { | |
restrict: 'E', | |
template: '<iframe width="100%" height="465" scrolling="no" frameborder="no"></iframe>', | |
link: function (scope, element, attrs) { | |
var iframe = element.find('iframe'); | |
var settings = [ | |
'buying=false', | |
'liking=false', | |
'download=false', | |
'sharing=false', | |
'show_artwork=true', | |
'show_comments=false', | |
'show_playcount=true', | |
'show_user=true', | |
'hide_related=true', | |
'visual=true', | |
'start_track=0', | |
'callback=true' | |
]; | |
var url = attrs.url + '?' + settings.join('&'); | |
iframe.attr('src', 'https://w.soundcloud.com/player/?url=' + url); | |
SC.Widget(iframe.get(0)); | |
} | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dependencies
Depends on https://w.soundcloud.com/player/api.js
Usage
In your HTML template
Resources
https://developers.soundcloud.com/blog/html5-widget-api
https://developers.soundcloud.com/docs/api/html5-widget