android - 使用VideoView的多个实例时出错

时间:2014-01-14 10:42:59

标签: java android android-mediaplayer android-videoview

我想要一个以线性布局显示两个(或更多)视频的活动。

使用带有本地文件作为数据源的videoview一切正常,但是使用视频流rtsp我有一个类似(1,1)的Mediaplayer错误代码,通常第一个视频显示正确,第二个显示错误。

我一次尝试两个流,它们有效,所以没有格式错误。

我读过有关媒体播放器资源发布的内容(link),但我需要显示每个实时视频。

这是我的活动中的代码:

   try{
    videoView = (VideoView) findViewById(R.id.videoView1);
    Uri video = Uri.parse(urlVideo+"1"); 
    videoView.setVideoURI(video);
    videoView.start();

    videoView2 = (VideoView) findViewById(R.id.videoView2);
    Uri video2 = Uri.parse(urlVideo+"0");
    videoView2.setVideoURI(video2);
    videoView2.start();
}
catch (Exception e) { 
    e.printStackTrace(); 
}

这是logcat上的完整错误:

    01-14 10:57:26.627: I/Crayon_Player(148): <== setDataSource(rtsp://192.168.4.125:554/0)
01-14 10:57:26.627: V/MediaPlayerService(148): [200] setVideoSurfaceTexture(0x1b808e0)
01-14 10:57:26.627: I/Crayon_Player(148): ==> setVideoSurfaceTexture(0x1b808e0)
01-14 10:57:26.627: I/RTSPEngine(148): @@@VOLOG Info THD 019EBA08:    utility.cpp  MakeLog  990    2419010028 DESCRIBE rtsp://192.168.4.125:554/1 RTSP/1.0

01-14 10:57:26.627: I/RTSPEngine(148): CSeq: 1

01-14 10:57:26.627: I/RTSPEngine(148): Accept: application/sdp

01-14 10:57:26.627: I/RTSPEngine(148): Accept-Encoding: identity

01-14 10:57:26.627: I/RTSPEngine(148): Content-Encoding: identity

01-14 10:57:26.627: I/RTSPEngine(148): Content-Language: en-US

01-14 10:57:26.627: I/RTSPEngine(148): User-Agent: Player/LG Player 1.0 for Android(stagefright alternative)

01-14 10:57:26.627: I/RTSPEngine(148): 

01-14 10:57:26.627: I/RTSPEngine(148): @@@VOLOG Info THD 019EBA08:    utility.cpp  MakeLog  990    2419010028 

01-14 10:57:26.627: I/Crayon_Player(148): <== setVideoSurfaceTexture(0x1b808e0) return=0
01-14 10:57:26.627: V/MediaPlayerService(148): [200] setVideoSurfaceTexture(0x18fb118)
01-14 10:57:26.627: V/MediaPlayerService(148): [200] setAudioStreamType(3)
01-14 10:57:26.627: V/MediaPlayerService(148): [200] prepareAsync
01-14 10:57:26.627: I/Crayon_Player(148): ==> prepareAsync
01-14 10:57:26.627: I/Crayon_Player(148): <== prepareAsync return=0
01-14 10:57:26.627: I/CrayonGraph-PlayerOMX(148): [SetURL] url=rtsp://192.168.4.125:554/0
01-14 10:57:26.627: E/CRTSPSource(148): @@@VOLOG Error THD 019ECCC8:   CRTSPSource.cpp  LoadSource  247    The RTSP Source didn't close correctly!
01-14 10:57:26.627: E/voCOMXFileSource(148): @@@VOLOG Error THD 019ECCC8:   voCOMXFileSource.cpp  LoadFile  1010    m_pSource->LoadSource was failed. 0X80000007
01-14 10:57:26.627: W/CrayonGraph-Base(148): [setParameter] comp=OMX.VisualOn.FileSource, paramIndex=0x100000d, pData=0x1915120, eRet = 0x80001001 
01-14 10:57:26.627: E/CrayonGraph-PlayerOMX(148): [setURI] OMX_IndexParamContentURI fail 1
01-14 10:57:26.627: E/CrayonGraph-PlayerBuilder(148): setURI fail 1
01-14 10:57:26.627: E/Crayon_PlayerEngine(148): ERROR!! notifyListener_l msg[100] ext1[1] ext2[1]
01-14 10:57:26.627: V/MediaPlayerService(148): [200] notify (0x190da70, 100, 1, 1)
01-14 10:57:26.627: E/MediaPlayer(31866): error (1, 1)

1 个答案:

答案 0 :(得分:1)

我还没有看到一个设备可以支持超过4个VideoView(或meadia播放器,或stagefright,或OpenMAX)的并发活动实例。如果您的CPU足够强大,您应该使用软件解决方案(ffmpeg或gstreamer)。