Android的4.1 - 使用VideoView和MediaController RTSPAndroid、VideoView、RTSP、MediaController

2023-09-06 02:18:08 作者:爱尔兰百年约

开发一个简单的应用程序在Android 4.1中发挥RTSP流,但未能如愿。

更新

我能能,如果我使用BigBuckBunny_115k.mov玩

 开放的视频= Uri.parse(RTSP://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov);
 

但 我试着用很多RTSP流这里提及和的此处,但没有工作:(的

*的的问题:我看不到我的手机上的任何流,只有黑色的屏幕是可见的。经过一段时间后,会出现一个对话框无法播放此视频。我试着用很多RTSP流,但同样的结果,那么,这所有的数据流中提到的问题?或者.sdp没有被正确分析?在code段是缺什么吗? * 的

 公共类MainActivity延伸活动{


    @覆盖
    保护无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.activity_main);
        VideoView videoView =(VideoView)findViewById(R.id.video);
        的MediaController的MediaController =新的MediaController(本);
        mediaController.setAnchorView(videoView);
        mediaController.setMediaPlayer(videoView);

        乌里视频= Uri.parse(RTSP://ss1c6.idc.mundu.tv:554 / prf0 / cid_29.sdp);
        videoView.setMediaController(的MediaController);
        videoView.setVideoURI(视频)
        videoView.start();
    }
 

 < VideoView
    机器人:ID =@ + ID /视频
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =WRAP_CONTENT
    机器人:layout_alignParentBottom =真
    机器人:layout_alignParentLeft =真
    机器人:layout_alignParentRight =真
    机器人:layout_alignParentTop =真/>
 
windows media center怎么用

 <使用-SDK
    安卓的minSdkVersion =11
    机器人:targetSdkVersion =17/>
<使用-权限的Andr​​oid:名称=android.permission.INTERNET对/>

<应用
    机器人:allowBackup =真
    机器人:图标=@可绘制/ ic_launcher
    机器人:标签=@字符串/ APP_NAME
    机器人:主题=@风格/ AppTheme>
    <活动
        机器人:名称=com.rdx.livetv.MainActivity
        机器人:标签=@字符串/ APP_NAME>
        <意向滤光器>
            <作用机器人:名称=android.intent.action.MAIN/>

            <类机器人:名称=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;
< /用途>
 

  10-08 17:53:03.674:D / libEGL(22488):加载/vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
10-08 17:53:03.682:D / libEGL(22488):加载/vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
10-08 17:53:03.682:D / libEGL(22488):加载/vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
10-08 17:53:03.775:D / OpenGLRenderer(22488):启用调试模式0
10-08 17:53:03.783:D / MediaPlayer的(22488):可能在客户端无法打开文件,试图服务器端
10-08 17:53:03.900:D / MediaPlayer的(22488)的getMetaData
10-08 17:53:06.596:D / dalvikvm(22488):GC_CONCURRENT释放102K,免费2%11074K / 11207K,暂停14毫秒+ 3ms的,总42ms
10-08 17:55:05.799:E / MediaPlayer的(22488):错误(1,-2147483648)
10-08 17:55:05.799:E / MediaPlayer的(22488):错误(1,-2147483648)
10-08 17:55:05.799:D / VideoView(22488):错误:1,-2147483648
 

解决方案

我分析了使用这些链接中给出的流 openRTSP 。

openRTSP是一个可以用来打开,流,接收和(可选)是由一个RTSP URL指定的记录媒体流的命令行程序 - 也就是开头RTSP的网址://

使用这个工具,我发现大多数提到的SDP文件有问题,这是对未来的应用程序中的问题的原因。

Developing a simple app to play a RTSP stream on Android 4.1, but unable to do so

Update

I am able Able to play if I use BigBuckBunny_115k.mov

Uri video = Uri.parse("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov");

BUT I tried with lot of RTSP streams mentioned here and here, but none worked :(

*Problem: I could not see any stream on my phone, only black screen is visible.. After some time, a dialog box appears "Can't play this video". I tried with many RTSP streams, but same result, so is it issue with all the streams mentioned? Or .sdp is not parsed properly? Is something missing in the code snippet? *

public class MainActivity extends Activity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        VideoView videoView = (VideoView) findViewById(R.id.video);
        MediaController mediaController = new MediaController(this);
        mediaController.setAnchorView(videoView);
        mediaController.setMediaPlayer(videoView);

        Uri video = Uri.parse("rtsp://ss1c6.idc.mundu.tv:554/prf0/cid_29.sdp");
        videoView.setMediaController(mediaController);
        videoView.setVideoURI(video);
        videoView.start();
    }

<VideoView
    android:id="@+id/video"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true" />

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.rdx.livetv.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

10-08 17:53:03.674: D/libEGL(22488): loaded /vendor/lib/egl/libEGL_POWERVR_SGX540_120.so
10-08 17:53:03.682: D/libEGL(22488): loaded /vendor/lib/egl/libGLESv1_CM_POWERVR_SGX540_120.so
10-08 17:53:03.682: D/libEGL(22488): loaded /vendor/lib/egl/libGLESv2_POWERVR_SGX540_120.so
10-08 17:53:03.775: D/OpenGLRenderer(22488): Enabling debug mode 0
10-08 17:53:03.783: D/MediaPlayer(22488): Couldn't open file on client side, trying server side
10-08 17:53:03.900: D/MediaPlayer(22488): getMetadata
10-08 17:53:06.596: D/dalvikvm(22488): GC_CONCURRENT freed 102K, 2% free 11074K/11207K, paused 14ms+3ms, total 42ms
10-08 17:55:05.799: E/MediaPlayer(22488): error (1, -2147483648)
10-08 17:55:05.799: E/MediaPlayer(22488): Error (1,-2147483648)
10-08 17:55:05.799: D/VideoView(22488): Error: 1,-2147483648

解决方案

I analyzed the streams given in these links using openRTSP.

"openRTSP" is a command-line program that can be used to open, stream, receive, and (optionally) record media streams that are specified by a RTSP URL - i.e., an URL that begins with rtsp://

Using this utility, I found that most of the SDP files mentioned had issues, and this is the reason for the issues coming in the application.