我想在Dialog
框中播放视频,以响应ListView
itemclicked事件。 Dialog
打开,我收到以下消息:
无法播放此视频
代码如下:
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView < ? > parent, View view, int position, long id) {
final Dialog dialog = new Dialog(aikiorder.this);
dialog.setContentView(R.layout.aikiitemsample);
dialog.setTitle(aikiNames[position]);
Button b = (Button) dialog.findViewById(R.id.button2);
b.setText(getString(R.string.closeVideoText) + " - " + aikiNames[position]);
dialog.findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
final VideoView vv = (VideoView) dialog.findViewById(R.id.videoView2);
MediaController mc = new MediaController(getApplicationContext());
mc.setAnchorView(vv);
mc.setMediaPlayer(vv);
Uri video = Uri.parse("http://techslides.com/demos/sample-videos/small.mp4");
vv.setVideoURI(video);
vv.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
vv.start();
}
});
dialog.show();
}
});
答案 0 :(得分:0)
缺少的是清单文件中的以下行。
<uses-permission android:name="android.permission.INTERNET" />