toEmbedUrl static method
Converts track permalinks to the w.soundcloud.com/player widget URL.
Widget options (visual, show_artwork, show_comments, etc.) are taken
from the source URL query string. CMS iframe URLs are returned unchanged.
Implementation
static String toEmbedUrl(String url) {
final uri = Uri.parse(_normalizeUrl(url));
if (uri.host == 'w.soundcloud.com') {
return uri.toString();
}
if (uri.host.contains('soundcloud.com')) {
final trackUri = uri.replace(query: null, fragment: '');
final params = Map<String, String>.from(uri.queryParameters);
params['url'] = trackUri.toString();
return Uri(
scheme: 'https',
host: 'w.soundcloud.com',
path: '/player/',
queryParameters: params,
).toString();
}
return uri.toString();
}