无法使用videoview在Android的播放RTSP [英] Unable to play rtsp using videoview in android

查看:1470
本文介绍了无法使用videoview在Android的播放RTSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个RTSP服务器使用VLC。然后我写一个应用程序,这是我的code:

I have set up a RTSP server using VLC. then I write an app,this is my code:

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;
}

}

和我已经设置权限。但是这仍然无法播放。什么happend后,我按一下按钮。但是,如果我取代RTSP与其他这两:

and I already set the permission. but this still can not play. nothing happend after I click the button. But if I replace the rtsp with other this two:

  1. RTSP://218.204.223.237:554 /现场/ 1 / 66251FC11353191F / e7ooqwcfbqjoo80j.sdp

  1. rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp

rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp

rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp

应用程序将正常播放。任何一个可以告诉我为什么?并没有任何解决方案,以发挥VLC流???

the app will play correctly. can any one tell me why? and is there any solution to play the VLC stream???

谢谢

推荐答案

安卓真的只支持MPEG 4带的MOOV原子正确设置codeD基线规范。较新的设备支持的其他方法(HLS和放大器;高异形MPEG4类型),但不是所有的设备都会这样的。您的RTSP流必须使用基线配置文件进行编码。

Android really only supports mpeg 4 encoded baseline profile with the MOOV atom set correctly. Newer devices support other methods (HLS & higher profiled mpeg4 types) but not all device will work that way. Your rtsp stream must be encoding using the base line profile.

如果您在 VLC ,然后打开你的网络数据流,然后媒体信息,你可以看到codeCS你的流使用的音频和视频

If you open your RTSP stream in VLC and open your network stream and then MEdia Information you can see what codecs your stream is using for audio and video

下面是Android和支持的媒体更明确的信息:的http://developer.android.com/guide/appendix/media-formats.html#recommendations

Here is more definitive info on android and supported media : http://developer.android.com/guide/appendix/media-formats.html#recommendations

这篇关于无法使用videoview在Android的播放RTSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆