我现在正在做一个实验,基于2.3的stagefright 做一个几个视频同时播放, 现在两个视频同时解码没问题,但是显示有问题,
我的测试播放器xml文件这么描述的
</LinearLayout>
<SurfaceView android:id="@+id/surface_view"
android:layout_width="240px"
android:layout_height="100px">
</SurfaceView>
<SurfaceView android:id="@+id/second_view"
android:layout_width="240px"
android:layout_height="100px">
</SurfaceView>两个surfaceview,播放时:
mp = new MediaPlayer(); secondMP = new MediaPlayer();
mp.setOnErrorListener(this); secondMP.setOnErrorListener(this);
mp.setOnBufferingUpdateListener(this); secondMP.setOnBufferingUpdateListener(this);
mp.setOnCompletionListener(this); secondMP.setOnCompletionListener(this);
mp.setOnPreparedListener(this); secondMP.setOnPreparedListener(this);
//mp.setAudioStreamType(2); //secondMP.setAudioStreamType(2); // Set the surface for the video output
//mp.setDisplay(mPreview.getHolder().getSurface());
mp.setDisplay(mPreview.getHolder());
secondMP.setDisplay(secondPreview.getHolder());但是现在显示大部分时候只显示其中一个视频,声音可以同时听到了,请高手指点些思路。
我的测试播放器xml文件这么描述的
</LinearLayout>
<SurfaceView android:id="@+id/surface_view"
android:layout_width="240px"
android:layout_height="100px">
</SurfaceView>
<SurfaceView android:id="@+id/second_view"
android:layout_width="240px"
android:layout_height="100px">
</SurfaceView>两个surfaceview,播放时:
mp = new MediaPlayer(); secondMP = new MediaPlayer();
mp.setOnErrorListener(this); secondMP.setOnErrorListener(this);
mp.setOnBufferingUpdateListener(this); secondMP.setOnBufferingUpdateListener(this);
mp.setOnCompletionListener(this); secondMP.setOnCompletionListener(this);
mp.setOnPreparedListener(this); secondMP.setOnPreparedListener(this);
//mp.setAudioStreamType(2); //secondMP.setAudioStreamType(2); // Set the surface for the video output
//mp.setDisplay(mPreview.getHolder().getSurface());
mp.setDisplay(mPreview.getHolder());
secondMP.setDisplay(secondPreview.getHolder());但是现在显示大部分时候只显示其中一个视频,声音可以同时听到了,请高手指点些思路。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货