如何检查android上的流式rtsp是否结束?

时间:2013-07-10 12:03:56

标签: android video-streaming rtsp rtsp-client

我有一个显示流媒体rtsp的应用程序。我该如何检查它是否结束? 缓冲空了?还有什么吗?

2 个答案:

答案 0 :(得分:0)

  • 套接字已关闭
  • 来自媒体服务器的控制通道上的任何内容?

答案 1 :(得分:0)

private VideoView vidView;
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        vidView = (VideoView) findViewById(R.id.myVideo);

        uri = Uri.parse(RTSP_URL);
        vidView.setMediaController(new MediaController(this));
        vidView.setVideoURI(uri);
        vidView.requestFocus();

        vidView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {

                Runnable runnable = new Runnable() {
                    @Override
                    public void run() {

                        vidView.start();

                    }
                };
                runOnUiThread(runnable);
            }
        });
        vidView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
            @Override
            public boolean onError(MediaPlayer mp, int what, int extra) {
                Log.d("Error ", what + " " + extra);
                return false;
            }
        });
        vidView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mp) {
                Log.d(getClass().getName(), " callback COMPLETE HERE ");

            }
        });


    }