Complementando, agora estou usando incializando um handler no onStartCommand() e utilizando ele pra mandar os comandos:
Mas ao tentar dar play estou recebendo no logcat:
-- public void playPlayer() {
stopPlayer();
mPlayerHandler.post(new Runnable() {
@Override
public void run() {
try {
mPlayer = new MultiPlayer(MyService.this, MultiPlayer.DEFAULT_AUDIO_BUFFER_CAPACITY_MS, MultiPlayer.DEFAULT_DECODE_BUFFER_CAPACITY_MS);
mPlayer.play(getResources().getString(R.string.url_streaming));
String stringTimeLimit = PreferenceManager.getDefaultSharedPreferences(MyService.this)
.getString(getResources().getString(R.string.PREFKEY_LIMITCONNECTION), "10");
int limit = Integer.parseInt(stringTimeLimit);
startTimeLimitCountDown(limit);
} catch (Exception e) {
e.printStackTrace();
playerException(null);
}
}
});
}
public void stopPlayer() {
mPlayerHandler.post(new Runnable() {
@Override
public void run() {
if (mPlayer != null) {
mPlayer.stop();
}
}
});
}Mas ao tentar dar play estou recebendo no logcat:
08-19 10:59:28.229 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ android.os.NetworkOnMainThreadException
08-19 10:59:28.229 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1147)
08-19 10:59:28.229 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at java.net.InetAddress.lookupHostByName(InetAddress.java:418)
08-19 10:59:28.229 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
08-19 10:59:28.229 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at java.net.InetAddress.getAllByName(InetAddress.java:215)
08-19 10:59:28.229 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.okhttp.HostResolver$1.getAllByName(HostResolver.java:29)
08-19 10:59:28.229 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:232)
08-19 10:59:28.229 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.okhttp.internal.http.RouteSelector.next(RouteSelector.java:124)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:272)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:382)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.spoledge.aacdecoder.AACPlayer.openConnection(AACPlayer.java:551)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.spoledge.aacdecoder.AACPlayer.play(AACPlayer.java:328)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.spoledge.aacdecoder.AACPlayer.play(AACPlayer.java:313)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.informatheus.webradiosertaovibe.service.MyService$1.run(MyService.java:135)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:739)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at android.os.Looper.loop(Looper.java:135)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5254)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at java.lang.reflect.Method.invoke(Native Method)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:372)
08-19 10:59:28.230 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
08-19 10:59:28.231 31666-31666/com.informatheus.webradiosertaovibe W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)You received this message because you are subscribed to the Google Groups "Android Brasil - Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to androidbrasil-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.






0 comentários:
Postar um comentário