Using the soundcloud api's RESOLVE from vb.net

2019-09-13 01:30发布

问题:

I have a website written in vb.net (actually asp.net using VB) and I want to allow users to view soundcloud videos embedded in pages. The idea is to use the javascript api to add a particular feature that a specialized subset of users might want.

I need the ability from javascript to make the audio do such actions as: 1) play 2) pause 3) seek

also, I need to get events from the audio to tell me when the audio has 1) paused 2) started to play and 3) seeked and 4) ended.

This is fairly basic, and I have read some of the documentation, but for guidance in reading the rest, I have the following questions:

  1. If someone agrees to allow his soundcloud file to be used on my website, does he have to set 'enable-api' or other settings? If so, does he do that on the "upload" page?

  2. Does soundcloud have private permissions like Youtube does? In Youtube, you can make a video public, but you can also make it shareable by only a circle of friends. If a third party (me, for instance) embeds one of those videos in his own website, only users who have logged in to Youtube on that browser can see that video. Does soundcloud have something analogous? This is a good feature to have, because if a user has doubts about my security, he can still rely on Youtube or Soundcloud security.

  3. If a user gives me a URL to his soundcloud audio, my program would need to use 'resolve' to find out the sound cloud ID, so it can embed the audio in a webpage. The programming language involved is oauth 2, one which I am not familiar with. Here is an example from the documentation, but how does this translate to Microsoft's dot-net languages?

example follows:

create client with your app's credentials

client = Soundcloud.new(:client_id => 'YOUR_CLIENT_ID')

a permalink to a track

track_url = 'http://soundcloud.com/forss/voca-nomen-tuum'

resolve track URL into track resource

track = client.get('/resolve', :url => track_url)

  1. I registered, so I have a clientID now, but where does that come in my website (apart from the above example)? Is it required to make javascript calls work?

  2. If my website is used enough, I might try to make money off it with advertisements. Does soundcloud allow that?

Thanks.

回答1:

  1. yes, users have options to set tracks in public and private, if track is public then you can access via API.

step for getting tracks on your Website.

  1. Use Resolve API. eg.
http://api.soundcloud.com/resolve?url={your track url}&client_id=YOUR_CLIENT_ID
  1. After reolve you get JSON Format data, and extract id from data.
  2. Pass track id in following Link
  https://api.soundcloud.com/i1/tracks/{trackid}/streams?client_id=02gUJC0hH2ct1EGOcYXQIzRFU91c72Ea&app_version=1467192015
  1. you get preview_mp3_128_url in json format, just extract it and use it on your website.