首先,我是Java和Android开发的新手,但我正在尝试从binpress运行Android的RadioStreams SDK。我在eclipse控制台中附加了示例代码和我从LogCat获取的错误。我只是想弄清楚为什么这个例子不起作用。我的长期目标是将其整合到Titanium中。
我知道这个问题可能很模糊,但是非常感谢有关连接或流式传输.pls或m3u文件的任何一般信息。
公共类MainActivity扩展了Activity {
private static final String TAG = "RsModule";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final HTTPRadio radio;
try {
radio = new HTTPRadio(new URI("http://mfm.ice.infomaniak.ch/playlists/mfm-64.aac.m3u"));
radio.play();
radio.setRadioChangeListener(new RadioChangeListener() {
public void radioStateChanged(final RadioState state) {
runOnUiThread(new Runnable() {
public void run() {
switch (state) {
case RADIO_STATE_BUFFERING:
Log.d(TAG,"Status: Buffering");
break;
case RADIO_STATE_CONNECTING:
Log.d(TAG,"Status: Connecting");
break;
case RADIO_STATE_PLAYING:
Log.d(TAG,"Status: Playing");
break;
case RADIO_STATE_STOPPED:
Log.d(TAG,"Status: Stopped");
break;
case RADIO_STATE_ERROR:
switch (radio.getRadioError()) {
case RADIO_ERROR_PLAYLIST_PARSING:
Log.d(TAG,"Status: Playlist Parsing Error");
break;
case RADIO_ERROR_DECODING:
Log.d(TAG,"Status: Decoding Error");
break;
case RADIO_ERROR_NETWORK_ERROR:
Log.d(TAG,"Status: Network Error");
break;
case RADIO_ERROR_FILE_STREAM_OPEN:
Log.d(TAG,"Status: Stream Open Error");
break;
default:
Log.d(TAG,"Status: Error");
}
break;
}
}
});
}
public void radioMetadataChanged(final IcyMetadata metadata) {
runOnUiThread(new Runnable() {
public void run() {
Log.d(TAG,"Now Playing: " + metadata.radioTitle);
}
});
}
});
} catch (ProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
LogCat控制台
04-25 20:25:36.987:I / ActivityManager(60):开始活动:意图{act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] flg = 0x10000000 cmp = com .example.rs / .MainActivity}
04-25 20:25:37.007:I / ActivityManager(60):启动proc com.example.rs以获取活动com.example.rs/.MainActivity:pid = 773 uid = 10037 gids = {}
04-25 20:25:37.037:D / AndroidRuntime(767):关闭虚拟机
04-25 20:25:37.037:D / dalvikvm(767):调试器已分离;对象注册表有1个条目
04-25 20:25:37.097:I / AndroidRuntime(767):注意:附加线程'Binder Thread#3'失败
04-25 20:25:37.678:D / dalvikvm(773):尝试加载lib /data/data/com.example.rs/lib/libradiostreams.so 0x43e37910
04-25 20:25:37.698:D / dalvikvm(773):添加了共享库/data/data/com.example.rs/lib/libradiostreams.so 0x43e37910
04-25 20:25:37.698:D / dalvikvm(773):在/data/data/com.example.rs/lib/libradiostreams.so 0x43e37910中找不到JNI_OnLoad,跳过init
04-25 20:25:37.708:I / RadioStreams(773):解析状态:/plaialsists/mfm-64.aac.m3u
04-25 20:25:37.937:I / ActivityManager(60):显示的活动com.example.rs/.MainActivity:935 ms(总计935 ms)
04-25 20:25:38.287:D / RadioStreams(773):状态:网络错误
04-25 20:25:43.147:D / dalvikvm(120):GC_EXPLICIT在134ms内释放了702个对象/ 39184个字节
04-25 20:25:48.198:D / dalvikvm(288):GC_EXPLICIT在132ms内释放了83个对象/ 3896个字节
04-25 20:25:53.257:D / dalvikvm(279):GC_EXPLICIT在132ms内释放了172个对象/ 11936个字节
04-25 20:29:14.911:D / SntpClient(60):请求时间失败:java.net.SocketException:协议不支持的地址族
04-25 20:34:14.958:D / SntpClient(60):请求时间失败:java.net.SocketException:协议不支持的地址族