android如何通过输入流播放视频

时间:2016-01-21 08:47:57

标签: android inputstream

我从socket看到CCTV的输入流,但我不知道如何将其显示为视频,有没有API?换句话说,android如何显示CCTV ???

我的问题:我使用视频框架来显示视频,该视频由字符串路径显示。 但我想要的是通过流显示......我怎么能弄清楚???

帮助我....

`void playfunction(){
     String path = "";
     VideoView mVideoView;
     EditText mEditText;
    mEditText = (EditText) findViewById(R.id.url);
    mVideoView = (VideoView) findViewById(R.id.surface_view);

//      path="http://dlqncdn.miaopai.com/stream/MVaux41A4lkuWloBbGUGaQ__.mp4";
    path = Environment.getExternalStorageDirectory().getAbsolutePath() + "/cctvwatch.mp4";
  if (path == "") {
        // Tell the user to provide a media file URL/path.
        Toast.makeText(VideoViewDemo.this, "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();
        return;
    } else {
        /*
         * Alternatively,for streaming media you can use
         * mVideoView.setVideoURI(Uri.parse(URLstring));
         */

        mVideoView.setVideoPath(path);
        mVideoView.setMediaController(new MediaController(this));
        mVideoView.requestFocus();

        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                // optional need Vitamio 4.0
                mediaPlayer.setPlaybackSpeed(1.0f);
            }
        });
    }
}

}`

0 个答案:

没有答案