我创建了一个基于this sample的简单UDP流应用,它有很多流地址我有两个按钮"下一个流" ,"上一个流" 。
当我点击"下一个流" libvlc实例将播放下一个流地址,并在单击上一个流时反之亦然。这么简单
这是我的代码
//first time create player,
releasePlayer1();
try {
// Create a new media player
player1 = LibVLC.getInstance();
player1.setHardwareAcceleration(LibVLC.HW_ACCELERATION_FULL);
player1.eventVideoPlayerActivityCreated(true);
player1.setSubtitlesEncoding("");
player1.setAout(LibVLC.AOUT_OPENSLES);
player1.setTimeStretching(true);
player1.setChroma("RV32");
player1.setVerboseMode(true);
LibVLC.restart(getActivity());
EventHandler.getInstance().addHandler(mHandlerPlayer1);
holderPlayer1.setFormat(PixelFormat.RGBX_8888);
holderPlayer1.setKeepScreenOn(true);
MediaList list = player1.getMediaList();
list.clear();
JSONArray jsonArray = new JSONArray(settings.getPlayer1Address());
for (int i = 0; i < jsonArray.length(); i++) {
list.add(new Media(player1, LibVLC.PathToURI(jsonArray.getString(i))), false);
}
player1.playIndex(0);
....
//next click
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
player1.playIndex(selectedVideo);
}
});
当应用程序启动它显示第一个网址就好了,但问题是当我点击下一步时我在此行上获得Anr异常
player1.playIndex(selectedVideo);
预先在这行libvlc类
中playMRL(mLibVlcInstance, mrl, options);
任何人都可以帮我解决这个问题吗?