Skip to content
zanxiaofei edited this page Jul 27, 2017 · 2 revisions

视频预览

短视频Demo中演示了合成上传后的视频的预览

1. 获取上传后播放地址

server)实现仅供参考,不提供上线服务

    //获取ks3播放地址,仅供demo使用,不提供上线服务
    private static String FILE_URL_SERVER = "http://ksvs-demo.ks-live.com:8720/api/upload/ks3/signurl";
    private String mCurObjectKey  //上传文件路径  

    mPlayurlGetTask = new HttpRequestTask(new HttpRequestTask.HttpResponseListener() {
                            @Override
                            public void onHttpResponse(int responseCode, String response) {
                                if (responseCode == 200) {
                                    if (!TextUtils.isEmpty(response)) {
                                        try {
                                            JSONObject data = new JSONObject(response);

                                            if (data.getInt("errno") == 0) {
                                                String url = data.getString("presigned_url");
                                                if (!url.contains("http")) {
                                                    url = "http://" + url;
                                                }
                                                //url即为获取的ks3的播放地址  
                                                mFilePath = url;
                                                EditActivity.this.mComposeAlertDialog.startPreview();
                                            }
                                        } catch (JSONException e) {
                                            e.printStackTrace();
                                            //播放合成后的视频
                                            EditActivity.this.mComposeAlertDialog.startPreview();
                                        }

                                    }
                                }
                            }
                        });
                        mPlayurlGetTask.execute(FILE_URL_SERVER + "?objkey=" + mCurObjectKey);

2. 播放视频

Demo中使用金山云播放SDK进行视频的预览,详细请移步对应wiki

Clone this wiki locally