Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Java
You last visited: Today at 13:32

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[JAVA] Download/Abspielen von SoundCloud

Discussion on [JAVA] Download/Abspielen von SoundCloud within the Java forum part of the Coders Den category.

Reply
 
Old   #1
 
Zunft's Avatar
 
elite*gold: 0
Join Date: Mar 2013
Posts: 3,185
Received Thanks: 1,317
[JAVA] Download/Abspielen von SoundCloud

Benötigte Externe Bibliotheken:



Code:
import de.voidplus.soundcloud.*; //SoundCloud API
import ddf.minim.*; //Minim Libary als Medienwiedergabemodul
import java.util.*;
import java.net.*;
import java.io.*;
import javax.swing.JOptionPane;

/**
 *
 * @author Tobias H. (aka Zunft)
 * @date 21.01.2014 
 *
 */
public class SoundDownloader extends Thread
{

    
    static SoundCloud soundcloud;
    static Minim minim;
    static AudioPlayer player;
    static String[] urlParts = null;
    static ArrayList<Track> result = null;
   
    
    public static void downloadbutton()
    {
        soundcloud = new SoundCloud(CLIENT_ID, SECRET_KEY); //Tokens für CLIENT_ID und SECRET_KEY werden nach der Registrierung einer SoundCloud-Software angezeigt
        
        urlananlyzer(); //Url splitten / Track ID herausfinden
        
        result = soundcloud.findTrack(urlParts[4]); //Track ID suchen
        if(result!=null)
		{

        try
        {
            
            download(); 
            
        }
        catch(Exception e)
        {
            javax.swing.JOptionPane.showConfirmDialog((java.awt.Component)
			null,e.getMessage(), "Error",
			javax.swing.JOptionPane.DEFAULT_OPTION);
		}
	}
    }
    public static void download()
 {
     
     
    String site= result.get(0).getStreamUrl(); //Download-Adresse
    String filename=DATA_NAME; //Name, der herunterzuladenen Datei
    try 
	{
		//Download
        URL url = new URL(site);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        int filesize = connection.getContentLength();
        float totalDataRead=0;
        java.io.BufferedInputStream in = new java.io.BufferedInputStream(connection.getInputStream());
        java.io.FileOutputStream fos = new java.io.FileOutputStream(filename);
        java.io.BufferedOutputStream bout = new BufferedOutputStream(fos,1024);
        byte[] data = new byte[1024];
        int i=0;
        while((i=in.read(data,0,1024))>=0)
        {
            totalDataRead=totalDataRead+i;
            bout.write(data,0,i);
            float Percent=(totalDataRead*100)/filesize;
            jProgressBar1.setValue((int)Percent);
        }  
		
        bout.close();
        in.close();
    }
    catch(Exception e)
    {
         javax.swing.JOptionPane.showConfirmDialog((java.awt.Component)
         null,e.getMessage(), "Error",
         javax.swing.JOptionPane.DEFAULT_OPTION);
    }
 }
    
    public void play()
    {
        soundcloud = new SoundCloud(CLIENT_ID, SECRET_KEY); //s.o.
        
        
        urlananlyzer(); //s.o.
        
        ArrayList<Track> result = soundcloud.findTrack(urlParts[4]); //s.o.
        if(result!=null)
		{
			//Wiedergabe
			minim = new Minim(this);
			player = minim.loadFile(result.get(0).getStreamUrl());
			player.play();
		}
    }
    
    public static void urlananlyzer()
	{
		urlParts = track.split("/"); //URL wird bei jedem '/' gesplittet.
	}
	
}
Zunft is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
Java download seite offline?
10/13/2013 - Off Topic - 6 Replies
Hey leute, seit gestern ist etwas komisches bei mir Zuhause los. Ich hab auf meinen Laptop wieder XP drauf installiert und musste auch später wieder Java runterladen und installieren. Ist ja kein Problem. Allerdings steht überall bei mir, also auf meinem Main-PC und Laptop, dass die Download-Seite also Http://javadl.sun.com/webapps/download/AutoDL?Bund leId=80819? offline ist. Komischerweise sind aber alle anderen "Java-seiten" online. Bei isup.me wird Java als "online" angezeigt. ...
[Download] New Java For 88 62 Version
02/09/2011 - MapleStory - 0 Replies
Hello! i giving u Java For V88 V62 Version's. דדדד.zip kostenlos von Uploading.com herunterladen
SoundCloud Desktop
01/19/2011 - Music - 0 Replies
Moin Musikfreunde! ich bin vor einigen Tagen auf ein Desktop Programm von SoundCloud gestoßen. Ihr könnt nach beliebigen Genres suchen und die gewünschten Titel sofort anhören oder herunterladen (kein Warez, auf SoundCloud kann jeder seine selbstgemixten Tracks hochladen). Die App gibt es ebenfalls für das Iphone sowie für Android-Geräte. SoundCloud Desktop



All times are GMT +2. The time now is 13:32.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.