我已经建立了一个RTSP服务器使用VLC。然后我写了一个应用程序,这是我的代码:
package com.ashley.work;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.VideoView;
public class TestPlayRTSP extends Activity {
Button playButton ;
VideoView videoView ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_play_rtsp);
videoView = (VideoView)this.findViewById(R.id.myvideoview);
playButton = (Button)this.findViewById(R.id.button1);
playButton.setOnClickListener(new Button.OnClickListener(){
public void onClick(View v) {
PlayRtspStream("rtsp://140.xxx.xxx.xxx:8554/");
}
});
}
private void PlayRtspStream(String rtspUrl){
videoView.setVideoURI(Uri.parse(rtspUrl));
videoView.requestFocus();
videoView.start();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_test_play_rtsp, menu);
return true;
}}
我已经设定了许可。但这仍然不能发挥。我按下按钮后什么也没发生。但如果我用其他两种方法来代替rtsp:
该应用程序将正确运行。有人能告诉我原因吗?有什么解决方案来播放VLC流吗?
谢谢
发布于 2012-11-08 15:19:38
Android实际上只支持mpeg 4编码的基线配置文件,MOOV设置正确。较新的设备支持其他方法(HLS &高级剖析的mpeg4类型),但并非所有设备都是这样工作的。您的rtsp流必须使用基线配置文件进行编码。
如果您在VLC中打开RTSP流,打开网络流,然后打开MEdia信息,您可以看到您的流用于音频和视频的编解码器
下面是关于android和支持的媒体的更明确的信息:http://developer.android.com/guide/appendix/media-formats.html#recommendations
https://stackoverflow.com/questions/13291632
复制相似问题