我的视频效果在mp4视频上非常完美,但对于实时流式传输iptv文件。它可以工作大约10到15秒然后停止,所以我必须一次又一次地重新打开活动
这是我的代码
VideoView myVideoView ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_channel2);
myVideoView = (VideoView) this .findViewById (R.id.channel2);
MediaController mc = new MediaController ( this );
myVideoView .setMediaController (mc);
final String urlStream = "http://192.168.111.55:8181" ;
runOnUiThread(new Runnable(){
@Override
public void run() {
myVideoView.setVideoURI(Uri.parse(urlStream));
}
});
myVideoView.start();
myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.setLooping(true);
}
});
}
}
XML
<VideoView
android:id="@+id/channel1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp" />