我正在尝试使用android vlc sdk播放RTMP视频,在屏幕上有多个实例,就像至少两个视频实例一样,问题在于它一次播放只有一个视频
package com.example.ajeet.libvlc;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Surface;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.FrameLayout;
import android.widget.VideoView;
import org.videolan.libvlc.IVideoPlayer;
import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.LibVlcException;
public class VideoVLCActivity extends Activity implements IVideoPlayer
{
private static final String TAG = VideoVLCActivity.class.getSimpleName();
//Size of Video
private int mVideoHeight;
private int mVideoWidth;
private int mVideoVisibleHeight;
private int mVideoVisibleWidth;
private int mSarNum;
private int mSarDen;
private SurfaceView mSurfaceView1,mSurfaceView2;
private FrameLayout mSurfaceFrame1,mSurfaceFrame2;
private SurfaceHolder mSurfaceHolder1,mSurfaceHolder2;
private Surface mSurface1,mSurface2 = null;
public LibVLC mLibVLC1,mLibVLC2;
private String mMediaUrl1,mMediaUrl2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "VideoVLC -- onCreate -- START ------------"); setContentView(R.layout.activity_video_vlc2);
//For first player
mSurfaceView1 = (SurfaceView)findViewById(R.id.player_surface1);
mSurfaceHolder1 = mSurfaceView1.getHolder();
mSurfaceFrame1 = (FrameLayout)findViewById(R.id.player_surface_frame1);
mMediaUrl1= getIntent().getExtras().getString("videoUrl");
try {
mLibVLC1 = new LibVLC();
mLibVLC1.setAout(mLibVLC1.AOUT_AUDIOTRACK);
mLibVLC1.setVout(mLibVLC1.VOUT_ANDROID_SURFACE);
mLibVLC1.setHardwareAcceleration(LibVLC.HW_ACCELERATION_FULL);
mLibVLC1.init(getApplicationContext());
}catch (LibVlcException e){
Log.e(TAG, e.toString());
}
mSurface1 = mSurfaceHolder1.getSurface();
mLibVLC1.attachSurface(mSurface1, VideoVLCActivity.this);
mLibVLC1.playMRL(mMediaUrl1);
//For SecondPlayer
mSurfaceView2 =(SurfaceView)findViewById(R.id.player_surface2);
mSurfaceHolder2 = mSurfaceView2.getHolder();
mSurfaceFrame2 = (FrameLayout)findViewById(R.id.player_surface_frame2);
mMediaUrl2= getIntent().getExtras().getString("videoUrl");
try {
mLibVLC2 = new LibVLC();
mLibVLC2.setAout(mLibVLC2.AOUT_AUDIOTRACK);
mLibVLC2.setVout(mLibVLC2.VOUT_ANDROID_SURFACE);
mLibVLC2.setHardwareAcceleration(LibVLC.HW_ACCELERATION_FULL);
mLibVLC2.init(getApplicationContext());
}catch (LibVlcException e){
Log.e(TAG,e.toString());
}
mSurface2 = mSurfaceHolder2.getSurface();
mLibVLC2.attachSurface(mSurface2,VideoVLCActivity.this);
mLibVLC2.playMRL(mMediaUrl2);
}
@Override
protected void onDestroy() {
super.onDestroy();
// MediaCodec opaque direct rendering should not be used anymore since there is no surface to attach.
mLibVLC1.stop();
mLibVLC2.stop();
}
public void eventHardwareAccelerationError() {
Log.e(TAG, "eventHardwareAccelerationError()!");
return;
}
@Override
public void setSurfaceLayout(final int width, final int height, int visible_width, int visible_height, final int sar_num, int sar_den){
Log.d(TAG, "setSurfaceSize -- START");
if (width * height == 0)
return;
// store video size
mVideoHeight = height;
mVideoWidth = width;
mVideoVisibleHeight = visible_height;
mVideoVisibleWidth = visible_width;
mSarNum = sar_num;
mSarDen = sar_den;
Log.d(TAG, "setSurfaceSize -- mMediaUrl: " + mMediaUrl1 + " mVideoHeight: " + mVideoHeight + " mVideoWidth: " + mVideoWidth + " mVideoVisibleHeight: " + mVideoVisibleHeight + " mVideoVisibleWidth: " + mVideoVisibleWidth + " mSarNum: " + mSarNum + " mSarDen: " + mSarDen);
Log.d(TAG, "setSurfaceSize -- mMediaUrl: " + mMediaUrl2 + " mVideoHeight: " + mVideoHeight + " mVideoWidth: " + mVideoWidth + " mVideoVisibleHeight: " + mVideoVisibleHeight + " mVideoVisibleWidth: " + mVideoVisibleWidth + " mSarNum: " + mSarNum + " mSarDen: " + mSarDen);
}
@Override
public int configureSurface(android.view.Surface surface, int i, int i1, int i2){
return -1;
}
}
这里是代码请帮助