我找到了应用程序代码,它(理论上)接收视频流并在VideoView对象上显示。
package com.example.cameraapp;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.MediaController;
import android.widget.VideoView;
import android.support.v4.app.NavUtils;
public class Camera extends Activity {
public VideoView mVideoView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_camera);
String LINK = "192.168.1.102:9889";
setContentView(R.layout.activity_camera);
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_camera, menu);
return true;
}
}
但是,当我运行VLC播放器时 - > Stream - > Http端口9889 - >转码MPEG-2 NO SOUND出现声明“不幸,无法显示此视频文件”。 我试过rtsp,转码H.264,但它没有帮助。 有谁知道它为什么不起作用?