PS.我正在跟踪登录错误日志,但我的应用程序没有停止不幸,我的显示器继续向我显示视频正在加载进度栏我设置在Asynctask,但当我检查日志猫我看到这个错误.
当然我已经在谷歌搜索过以及SO但我没有得到满意的结果.
Folowwing是我的日志猫消息.
02-21 11:08:52.964: W/SurfaceFlinger(101): nothing to do with mask 0x0000000002-21 11:08:52.974: W/System.err(1992): java.lang.RuntimeException: Can't create handler insIDe thread that has not called Looper.prepare()02-21 11:08:52.976: W/System.err(1992): at androID.os.Handler.<init>(Handler.java:121)02-21 11:08:52.976: W/System.err(1992): at androID.Widget.MediaController.<init>(MediaController.java:474)02-21 11:08:52.977: W/System.err(1992): at androID.Widget.MediaController.<init>(MediaController.java:474)02-21 11:08:52.978: W/System.err(1992): at androID.Widget.MediaController.<init>(MediaController.java:210)02-21 11:08:52.978: W/System.err(1992): at iqual.fIDol_final.ServerfileList.playVIDeo(ServerfileList.java:225)02-21 11:08:52.979: W/System.err(1992): at iqual.fIDol_final.ServerfileList.access(ServerfileList.java:221)02-21 11:08:52.979: W/System.err(1992): at iqual.fIDol_final.ServerfileList$PlayVIDeo.run(ServerfileList.java:181)02-21 11:08:52.979: W/System.err(1992): at java.lang.Thread.run(Thread.java:856)
以下是我的代码.
mListVIEw.setonItemClickListener(new OnItemClickListener() { @OverrIDe public voID onItemClick(AdapterVIEw<?> parent,VIEw vIEw,int position,long ID) { String url1 = null; Object o1 = myList.get(position); url1 = o1.toString().replace(" ","%20").trim(); playVIDeo = (PlayVIDeo) new PlayVIDeo(url1).execute(); } });
这是我播放视频的Asynctask
class PlayVIDeo extends AsyncTask<String,VoID,Boolean> { String baseURL; public PlayVIDeo(String baseURL) { this.baseURL = baseURL; } @OverrIDe protected voID onPreExecute() { super.onPreExecute(); pDialog = ProgressDialog.show(ServerfileList.this," Buffering...","please wait..",false); pDialog.setCancelable(false); } @OverrIDe protected Boolean doInBackground(String... urls) { Thread thread = new Thread(new Runnable() { @OverrIDe public voID run() { try { playVIDeo(baseURL); } catch (Exception e) { e.printstacktrace(); } } }); thread.start(); return true; } @OverrIDe protected voID onPostExecute(Boolean result) { super.onPostExecute(result); } }
以下是我的playVIDeo方法.
private voID playVIDeo(String baseURL) { Uri myUri = Uri.parse(baseURL); MediaController mc; mc = new MediaController(this); mVIDeoVIEw.setMediaController(mc); mVIDeoVIEw.setVIDeoURI(myUri); System.out.println("====Myuri=====" + myUri); mVIDeoVIEw.requestFocus(); mVIDeoVIEw.start(); }
我也尝试在doInbackground方法中创建新线程并通过删除线程,但这个技巧对我不起作用.
还有一件事,它在第225行显示错误,即mc = new MediaController(this);
解决方法 您可以使用以下代码删除AsyncTask并直接播放视频,String url1 = null; Object o1 = myList.get(position); url1 = o1.toString().replace(" ","%20").trim(); playVIDeo(url1);总结
以上是内存溢出为你收集整理的在android中从http服务器播放视频全部内容,希望文章能够帮你解决在android中从http服务器播放视频所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)