¿Cómo puedo usar SoundCloud en mi aplicación Android?
Quiero usar el soundcloud en mi aplicación android como esta: Quiero reproducir una canción en el reproductor de soundcloud con dirección de url. He utilizado código de seguimiento en la webview, pero no se ejecutó correctamente. ¿Cómo puedo hacer esto? Gracias.
<iframe width=\"100%\" height=\"166\" scrolling=\"no\" frameborder=\"no\" src=\"http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F31416027&auto_play=false&show_artwork=false&color=ff7700\"></iframe>
- Cómo mostrar / ocultar fragmento con el dedo hacia arriba / hacia abajo como la aplicación androide de soundcloud
- ¿Existe un límite de cuota para la API de SoundCloud?
- Efecto Parallax en cada elemento en una vista de reciclador?
- SoundCloud HTML5 Widget API - No funciona en Chrome para Android
- Búsqueda por filtro geográfico con soundcloud api
- URL de Soundcloud abierta en la aplicación nativa Soundcloud de WebView
- Cómo incrustar widget de SoundCloud en la aplicación para Android
- Uso de Facebook y Google Plus en la aplicación Android de SoundCloud
- Soundcloud SDK para Android
- Cómo utilizar SoundCloud API en Java (Android App)
- Compartir enlace de audio de terceros en la nube de sonido y youtube en la aplicación Android
¿Ha considerado utilizar el envolvente oficial de SoundCloud en Java ?
También he probado las soluciones de reproductores integrados con una webview, pero esto no funciona.
Ahora estoy utilizando el Soundbloud Java API Wrapper y esto funciona bien. Siga las instrucciones del reporte GitHub para implementar la API: https://github.com/soundcloud/java-api-wrapper
El código entonces es realmente directo. Sólo necesita un ID de cliente y un secreto de cliente, ambos tienen que ser obtenidos en el sitio web de desarrolladores de soundcloud.
El código entonces es realmente directo:
String id = getResources().getString(R.string.sc_client_id); String secret = getResources().getString(R.string.sc_client_secret); ApiWrapper wrapper = new ApiWrapper(id,secret, null, null); try { //Only needed for user-specific actions; //wrapper.login("<user>", "<pass>"); //HttpResponse resp = wrapper.get(Request.to("/me")); //Get a track HttpResponse trackResp = wrapper.get(Request.to("/tracks/60913196")); //Track JSON response OK? if(trackResp.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { JSONObject trackJSON = new JSONObject(EntityUtils.toString(trackResp.getEntity())); //If track is streamable, fetch the stream URL (mp3-https) and start the MediaPlayer if(trackJSON.getBoolean("streamable")) { HttpResponse streamResp = wrapper.get(Request.to("/tracks/60913196/stream")); JSONObject streamJSON = new JSONObject(EntityUtils.toString(streamResp.getEntity())); String streamurl = streamJSON.getString("location"); Log.i("SoundCloud", trackJSON.getString("streamable")); Log.i("SoundCloud", streamurl); m_soundcloudPlayer.stop(); m_soundcloudPlayer = new MediaPlayer(); m_soundcloudPlayer.setDataSource(streamurl); m_soundcloudPlayer.prepare(); m_soundcloudPlayer.start(); } } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); }
El objeto m_soundcloudPlayer
es un android.media.MediaPlayer
.
Estoy teniendo el mismo problema. Descubrí que la razón por la que el código de inserción estándar no funciona es debido a que el navegador de Android no admite códecs de audio HTML5. El mejor tiro es el envoltorio oficial, supongo, pero no estoy seguro de cómo hacer esto todavía (sólo un aficionado).
//In Activity_layout.xml <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <WebView android:id="@+id/webview" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> // In ActivityClass.java mSoundCloudPlayer =(WebView) findViewById(R.id.webview); String VIDEO_URL = "Set Your Embedded URL"; String html = "<!DOCTYPE html><html> <head> <meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"target-densitydpi=high-dpi\" /> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"> <link rel=\"stylesheet\" media=\"screen and (-webkit-device-pixel-ratio:1.5)\" href=\"hdpi.css\" /></head> <body style=\"background:black;margin:0 0 0 0; padding:0 0 0 0;\"> <iframe id=\"sc-widget " + "\" width=\"100%\" height=\"50%\"" + // Set Appropriate Width and Height that you want for SoundCloud Player " src=\"" + VIDEO_URL // Set Embedded url + "\" frameborder=\"no\" scrolling=\"no\"></iframe>" + "<script src=\"https://w.soundcloud.com/player/api.js\" type=\"text/javascript\"></script> </body> </html> "; mSoundCloudPlayer.setVisibility(View.VISIBLE); mSoundCloudPlayer.getSettings().setJavaScriptEnabled(true); mSoundCloudPlayer.getSettings().setLoadWithOverviewMode(true); mSoundCloudPlayer.getSettings().setUseWideViewPort(true); mSoundCloudPlayer.loadDataWithBaseURL("",html,"text/html", "UTF-8", "");
Yo había intentado utilizar SoundCloud Java Api Wrapper. Pero esa cosa me está dando error cuando intento conseguir la pista.
Eso está en la línea
HttpResponse trackResp = wrapper.get(Request.to("/tracks/60913196"));
Error: 13781-13781 / com.example.DDS.soundcloud E / Trace: error al abrir el archivo de rastreo: No existe ningún archivo o directorio (2)
Si alguien está teniendo el proyecto de trabajo de Soundcloud jugador en una aplicación para Android. Le ruego que comparta el proyecto con nosotros.