Entsprechend den Änderungen für kitakt 4.4 gab es einige Probleme beim Abspielen von Shoutcast-Streams (solche, die "ICY" anstelle von "HTTP/1.x" -Reaktion zurückliefern).Unerwartete Statuszeile: ICY 200 OK für URL-Methode openStream()?
So Lösung für kitkat war „eisigen“ Protokoll-Präfix in JVM neu registrieren einmal, bevor wir einen Strom durch diesen geöffnet:
try {
java.net.URL.setURLStreamHandlerFactory(new java.net.URLStreamHandlerFactory(){
public java.net.URLStreamHandler createURLStreamHandler(String protocol) {
Log.d(LOG, "Asking for stream handler for protocol: '" + protocol + "'");
if ("icy".equals(protocol)) return new com.spoledge.aacdecoder.IcyURLStreamHandler();
return null;
}
});
}
catch (Throwable t) {
Log.w(LOG, "Cannot set the ICY URLStreamHandler - maybe already set ? - " + t);
}
Ich habe Problem mit offenem Audio-Stream es registrieren zu machen. Nachdem ich url.opnestream (Strom) nennen bekam ich Ausnahme:
java.net.ProtocolException: Unerwarteter Statuszeile: ICY 200 OK
Wie kann ich das Problem beheben?
Hier ist ein Beispielaudio der Registrierung, so weit, was ich tat ..
try {
URL url = null;
url = new URL(u);
inputStream = url.openStream();
startTime = System.currentTimeMillis();
Boolean isSDPresent = android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
String fileName = File.separator + "radio_" + "recording_" + channelMetadata.replaceAll("\\W", "") + System.currentTimeMillis();
if(isSDPresent)
{
outputSource = Environment.getExternalStorageDirectory() + fileName;
}
else
{
outputSource = Environment.getDataDirectory() + fileName;
}
if(contentType.equals("audio/aacp"))
fileOutputStream = new FileOutputStream(outputSource + ".acc");
else if(contentType.equals("audio/mpeg"))
fileOutputStream = new FileOutputStream(outputSource + ".mp3");
else
fileOutputStream = new FileOutputStream(outputSource + ".nieznany_format");
int bytesRead = 0;
int bytes;
while (((bytes = inputStream.read()) != -1) && isRecording) {
fileOutputStream.write(bytes);
bytesRead++;
stopTime = System.currentTimeMillis();
long seconds = (Math.abs(startTime-stopTime));
int minutes = 1000 * 60 * 60;
if(minutes<=seconds)
{
Log.d("xxx", "recording task exceed stopped");
break;
}
}
inputStream.close();
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
isRecording = false;
}
isRecording = false;
return null;