有没有办法强制使用SoundCloud javascript流API的MP3块?

时间:2018-04-13 01:25:32

标签: api audio stream soundcloud chunks

据我所知,SoundCloud现在以10秒的MP3块发送“流”......然后以某种方式将整个事件作为单个MP3文件加入,在浏览器端播放。

他们还使用具有时间限制链接的Amazon Meastro Player。两者结合起来,它有助于防止音频盗窃(主要是“存储”问题)。

但是,当使用javascript流API(SC.stream)时,它回退到旧方法(将整个文件下载为“正常”,而不是块)。有没有办法强制采用这种新方法?

而且,在这里,有没有办法强制使用Opus Codec文件?

1 个答案:

答案 0 :(得分:1)

当您说“ MP3块”时,我假设您指的是HLS。该API将返回HLS mp3和Opus URL。

请求:

HTTP GET: https://api.soundcloud.com/tracks/90787841/streams&client_id{CLIENT_ID}

响应:

{
  "http_mp3_128_url": "https://cf-media.sndcdn.com/56LCadzDEBZn.128.mp3?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLW1lZGlhLnNuZGNkbi5jb20vNTZMQ2FkekRFQlpuLjEyOC5tcDMiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1MzY1MjEzNzF9fX1dfQ__\u0026Signature=sjO5rOEEHKOY8N~F8iqcm0Fb~6OWmpPpIwu1zVlpZWkNafvHR2hSLlHCQ3AprG0aNxKLABZc36~ciuvWZuEro~V99hsISdVwc8T0uISnLA99WhuWSryQ8THkC2de0PygtOdxXvdVxdKKki2xiyRMpd-mDyoePin6zYfNMzP1msTKTFk8TEB2Xc5MjzMJQA0VmxhFQwlEWraXJLUe03lB1-Zk1HkEtNHb2pNjuW-wxEmsfsrY0Nc6n-K7ORoiYMwJAFCxTrh06jv82tV01rU07gF0za5JKgmJUt4REIqgIJmJR9yHNJhpjqRn1mVmAthA9R7pD~t-kLFKHupm29O6zg__\u0026Key-Pair-Id=APKAJAGZ7VMH2PFPW6UQ",
  "hls_mp3_128_url": "https://cf-hls-media.sndcdn.com/playlist/56LCadzDEBZn.128.mp3/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1tZWRpYS5zbmRjZG4uY29tL3BsYXlsaXN0LzU2TENhZHpERUJabi4xMjgubXAzL3BsYXlsaXN0Lm0zdTgiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE1MzY1MjEzNzF9fX1dfQ__\u0026Signature=L-Mhlq55~oFIRBnzSXES-nAZnxGswJok9mxNksvCdVTXYlYooNrFOm4TvmR~uWLG5owEEitgs8PWkl0XVIZMFahYScRwoe7INKisImCBfGoSW1v6BJBjaVb7KaGl-usJ0NnRjpAPVFX1YwMuPsN22OToJWJOy2oudZfFwJ7e5K36Eifx9DH1WW6XChiaaE4ltlbAB2gSsFGT4qA1uT2AGSVXehB9iV2CK-fYyoL15hDM7kPVXb~tx5~kX3S1b3rj0j3f45WDn3nzACMugvX-1YXX7FJP0a2Niz7Qqw5TPkZhoqLdOzKzGGU9-oJY~NhZ9iH6vX0UYO7eGgiQo-Cmag__\u0026Key-Pair-Id=APKAJAGZ7VMH2PFPW6UQ",
  "hls_opus_64_url": "https://cf-hls-opus-media.sndcdn.com/playlist/56LCadzDEBZn.64.opus/playlist.m3u8?Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiKjovL2NmLWhscy1vcHVzLW1lZGlhLnNuZGNkbi5jb20vcGxheWxpc3QvNTZMQ2FkekRFQlpuLjY0Lm9wdXMvcGxheWxpc3QubTN1OCIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTUzNjUyMTM3MX19fV19\u0026Signature=P6cz9ZnjZcjFxeX2JZvsICbbCL4-gfg8It0gSiQ3ZyxVXdqipaa3RMpyRqz5HapRtR~50haa-hWwmv6M6qKs8As24a-f8UNDWaUgH9vlkc9gZWVF-hTqqQZJPzfHkRPyh8cwTort9gm7EM7W-BKS8P9JKvFEfpCteHF9QLETbKUSIj-woclIAvONKHYBumRh3C9HmB5K4M5fM0viG3bUd0S5IX7v3duL~GKIFrVJoB0vetPohve2EW4ymrkG5fsh~ge07j6cxD6dIh14rkRL6NXzizUkz4ZkblxdzUk~L35i6j0Z0nPPX~6SHyqV1~2tKbFq3fNkpiKko3SJz6Bf2w__\u0026Key-Pair-Id=APKAJAGZ7VMH2PFPW6UQ",
  "preview_mp3_128_url": "https://ec-preview-media.sndcdn.com/preview/0/30/56LCadzDEBZn.128.mp3?f10880d39085a94a0418a7e162b03d52e21adf826af17a391e1a741e362f9cfc19da4f852776a03740e74cddedca7636cfc4c0ee23dbbc0bfb95c6dc0119fdb9a1862203f883ed05b3fcda0c4e5455987eba"
}

此功能未在JS API中公开,您将需要使用HTTP REST API并将这些URL加载到其他播放器中。