Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Studio:如何使用streamscraper获取shoutcast元数据_Android_Audio Streaming_Shoutcast_Icecast_Internet Radio - Fatal编程技术网

Android Studio:如何使用streamscraper获取shoutcast元数据

Android Studio:如何使用streamscraper获取shoutcast元数据,android,audio-streaming,shoutcast,icecast,internet-radio,Android,Audio Streaming,Shoutcast,Icecast,Internet Radio,我是Android开发的新手。我想从Shoutcast服务器获取元数据,发现streamscraper是最容易使用的。但我的问题是,我不知道如何使用它。主页本身仅显示如何使用它: import java.net.URI; import java.util.List; import net.moraleboost.streamscraper.Stream; import net.moraleboost.streamscraper.Scraper; import net.moraleboost.st

我是Android开发的新手。我想从Shoutcast服务器获取元数据,发现streamscraper是最容易使用的。但我的问题是,我不知道如何使用它。主页本身仅显示如何使用它:

import java.net.URI;
import java.util.List;
import net.moraleboost.streamscraper.Stream;
import net.moraleboost.streamscraper.Scraper;
import net.moraleboost.streamscraper.scraper.IceCastScraper;

    public class Harvester {
     public static void main(String[] args) throws Exception {
      Scraper scraper = new IceCastScraper();
      List streams = scraper.scrape(new URI("http://host:port/"));
      for (Stream stream: streams) {
       System.out.println("Song Title: " + stream.getCurrentSong());
       System.out.println("URI: " + stream.getUri());
      }
     }
    }

在任何地方搜索都没有找到关于如何使用此功能的项目示例。我希望你们中的一位可以发布如何使用它的代码,或者为它制作一个教程。

无需使用外部库。以下几页为您提供了:

Current song:     http://yourstream:port/currentsong?sid=#
Last 20 songs:    http://yourstream:port/played.html?sid#
Next songs:       http://yourstream:port/nextsongs?sid=#
打印当前歌曲的Android java类:

import java.io.BufferedReader;
import java.io.InputStreamReader;    
import java.net.URL;

public class NowPlaying {

    public void CurrentSong() {

        try
        {
            URL url = new URL("http://www.mofosounds.com:8000/currentsong?sid=#");
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));

            String inputLine;

            while ((inputLine = in.readLine()) != null)
                System.out.println(inputLine);

            in.close();
        }
        catch(Exception e)
        {
            System.out.println(e.toString());
        }
    }
}

注意:流的播放器必须支持
nextsongs?sid=#
功能。

@downvoter,解释一下?这是一个完美的工作示例。这不会在所有流式服务器上都起作用。大多数服务器不实现这些端点,包括大多数部署的SHOUTcast版本。