2013-10-08 62 views
9

开发一个简单的应用在Android 4.1播放RTSP流,但未能如愿的Android 4.1 - RTSP使用VideoView和MediaController

更新

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

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

但 我试着用很多RTSP流mentioned herehere,但没有工作:(

****问题:我看不到我的手机上有任何流,只有黑色屏幕可见..过了一段时间后,出现一个对话框“无法播放此视频”。我尝试过很多RTSP流,但结果相同,所以提到的所有流都有问题?或.sdp未正确解析?代码片段中缺少某些内容吗? ****

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 

回答

6

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

“openRTSP”是一个命令行程序,可用于打开,流,接收和(可选)记录由RTSP URL指定的媒体流 - 即以rtsp://开头的URL

使用此实用程序,我发现提到的大多数SDP文件都有问题,这就是应用程序中出现问题的原因。

+0

它与Android开发有关吗? – alacerda

+0

@Rohit那么,你可以请那些需要像我这样的工作和非工作类别。 –

7

使用本地播放器播放RTSP的另一个很好的解决方案。

mediaURL = "rtsp://192.168.0.119/Bolt.ts" 
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mediaURL)); 
startActivity(intent); 
相关问题