我参考了这位朋友的做法,我的不会出界面http://ask.dcloud.net.cn/article/13410
官方集成说明:https://help.aliyun.com/document_detail/61908.html?spm=a2c4g.11186623.6.979.eef7533coq6MOI
求解,求解,求解,求解,来个官方的,这个对好多人都用的到
我的代码
private static final int REQUEST_CODE_RECORD_VIDEO= 1002;
private String pUrl="";
private String pErr="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
Intent intent = this.getIntent();
String datajson= intent.getCharSequenceExtra("datajson").toString();
try {
JSONObject object=new JSONObject(datajson);
pUrl=object.getString("url");
} catch (JSONException e){
e.printStackTrace();
}
AliVcMediaPlayer.init(getApplicationContext());
AliVcMediaPlayer mPlayer = new AliVcMediaPlayer(this,new SurfaceView(this));
mPlayer.setErrorListener(new MediaPlayer.MediaPlayerErrorListener() {
@Override
public void onError(int i, String msg) {
//错误发生时触发,错误码见接口文档
Log.println(i,"ERROR",msg);
pErr=msg;
}
});
mPlayer.prepareToPlay(pUrl);
mPlayer.play();
}
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
Intent intent=new Intent();
if(requestCode ==REQUEST_CODE_RECORD_VIDEO)
{
if(resultCode == Activity.RESULT_OK && data!= null)
{
intent.putExtra("resultCode","000000");
intent.putExtra("type","RECORD");
intent.putExtra("path",pUrl);
}else if(resultCode == Activity.RESULT_CANCELED)
{
intent.putExtra("err",pErr);
intent.putExtra("resultCode","-1");
}
}
else {intent.putExtra("resultCode","-2");}
setResult(RESULT_OK,intent);
this.finish();
}
0 个回复