diff --git a/demo/app/build.gradle b/demo/app/build.gradle index e2d93e1..ed3b89f 100644 --- a/demo/app/build.gradle +++ b/demo/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "com.ksyun.media.shortvideo.demo" minSdkVersion 19 targetSdkVersion 24 - versionCode 142 - versionName "1.4.2" + versionCode 146 + versionName "1.4.6" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } sourceSets { @@ -40,8 +40,8 @@ dependencies { compile 'com.facebook.fresco:fresco:1.4.0' compile 'com.facebook.fresco:animated-gif:1.4.0' compile 'com.facebook.fresco:animated-webp:1.4.0' - compile 'com.ksyun.media:libksysv-java:1.4.2' - compile 'com.ksyun.media:libksysv-arm64:1.4.2' - compile 'com.ksyun.media:libksysv-armv7a:1.4.2' - compile 'com.ksyun.media:libksysv-x86:1.4.2' + compile 'com.ksyun.media:libksysv-java:1.4.6' + compile 'com.ksyun.media:libksysv-arm64:1.4.6' + compile 'com.ksyun.media:libksysv-armv7a:1.4.6' + compile 'com.ksyun.media:libksysv-x86:1.4.6' } diff --git a/demo/app/src/main/assets/AuthForTest.pkg b/demo/app/src/main/assets/AuthForTest.pkg new file mode 100644 index 0000000..c7aca78 --- /dev/null +++ b/demo/app/src/main/assets/AuthForTest.pkg @@ -0,0 +1 @@ +h1iuRSzMW60Iwm2XzBzu40UnPMP4Td2X2Ab5JAKtfDD3kzmND4Hc6McUvbtvI+TVSRmMsXYCynqIqMnlzLtS+srE1B4bkh4ZQ5GxVttDe2ldWspDUxwBdEk+8fI3l11UhZXZZh2XEoJ2reqytoneKQbVIqt7UrZFd4Wx9a6Tpp4=SZs8qatUU89FFTWMLWeM6KFxtsJOI2dS6COArBPYvrzJEVfVRk/2u80JsfX+JrvuGY6yTs/SMw6lTqZF0zcB67na0znaGd0ahfeRKm0dihOMjk9BtTmeWk4HH5i64rM8/7r/bh2NIRZGICsgpJzKW5w7wBLH3GHo7vmaiDblj60= \ No newline at end of file diff --git a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java index 760473f..268348b 100644 --- a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java +++ b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/EditActivity.java @@ -1543,6 +1543,8 @@ public void onClick(View view) { mOutForGIF.setActivated(false); mOutEncodeWithH264.setEnabled(true); mOutEncodeWithH265.setEnabled(true); + mOutEncodeWithH264.setActivated(true); + mOutEncodeWithH265.setActivated(false); mOutEncodeByHW.setEnabled(true); break; case R.id.output_config_gif: diff --git a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/MediaImportActivity.java b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/MediaImportActivity.java index 553d43e..a444e53 100644 --- a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/MediaImportActivity.java +++ b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/MediaImportActivity.java @@ -12,6 +12,7 @@ import android.widget.Button; import android.widget.ImageButton; import android.widget.TextView; +import android.widget.Toast; import com.ksyun.media.shortvideo.demo.adapter.MediaGalleryAdapter; import com.ksyun.media.shortvideo.demo.adapter.MediaSelectedAdapter; @@ -114,10 +115,14 @@ private void onSelectedDataConfirmed() { for (int i = 0; i < list.size(); i++) { path.add(list.get(i).filePath); } - Intent intent = new Intent(); - intent.putStringArrayListExtra("filePath", path); - setResult(RESULT_CODE, intent); - finish(); + if (path.size() == 0) { + Toast.makeText(this, "请至少选择一个文件", Toast.LENGTH_SHORT).show(); + } else { + Intent intent = new Intent(); + intent.putStringArrayListExtra("filePath", path); + setResult(RESULT_CODE, intent); + finish(); + } } private class ButtonObserver implements View.OnClickListener { diff --git a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/ShortVideoActivity.java b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/ShortVideoActivity.java index 7b9507f..9ca0107 100644 --- a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/ShortVideoActivity.java +++ b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/ShortVideoActivity.java @@ -4,6 +4,7 @@ import com.ksyun.media.shortvideo.kit.KSYEditKit; import com.ksyun.media.shortvideo.utils.AuthInfoManager; +import org.apache.http.util.EncodingUtils; import org.json.JSONException; import org.json.JSONObject; @@ -12,6 +13,7 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; +import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; import android.view.View; @@ -22,6 +24,8 @@ import android.widget.TextView; import android.widget.Toast; +import java.io.InputStream; + /** * 引导窗口页 */ @@ -79,7 +83,7 @@ private void showWebView() { mDefaultView.setVisibility(View.GONE); mWebView.setVisibility(View.VISIBLE); mWebView.loadUrl(COLOPHON_URL); - mWebView.setWebViewClient(new WebViewClient(){ + mWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); @@ -102,7 +106,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { default: break; } - return super.onKeyDown(keyCode,event); + return super.onKeyDown(keyCode, event); } @Override @@ -122,73 +126,117 @@ public void onDestroy() { AuthInfoManager.getInstance().removeAuthResultListener(mCheckAuthResultListener); } - /** * SDK鉴权 */ private void checkAuth() { + String token = null; + try { + InputStream in = getResources().getAssets().open("AuthForTest.pkg"); - if (mAuthResponse == null) { - mAuthResponse = new HttpRequestTask.HttpResponseListener() { - @Override - public void onHttpResponse(int responseCode, String response) { - //params response - boolean authResult = false; - if (responseCode == 200) { - try { - JSONObject temp = new JSONObject(response); - JSONObject data = temp.getJSONObject("Data"); - int result = data.getInt("RetCode"); - if (result == 0) { - String authInfo = data.getString("Authorization"); - String date = data.getString("x-amz-date"); - //初始化鉴权信息 - AuthInfoManager.getInstance().setAuthInfo(authInfo, date); - //添加鉴权结果回调接口(不是必须) - AuthInfoManager.getInstance().addAuthResultListener(mCheckAuthResultListener); - //开始向KSServer申请鉴权 - AuthInfoManager.getInstance().checkAuth(); - authResult = true; - } else { - Log.e(TAG, "get auth failed from app server RetCode:" + result); - } - } catch (JSONException e) { - e.printStackTrace(); - Log.e(TAG, "get auth failed from app server json parse failed"); - } - } else { - Log.e(TAG, "get auth failed from app server responseCode:" + responseCode); - } + int length = in.available(); - final boolean finalAuthResult = authResult; - runOnUiThread(new Runnable() { + byte[] buffer = new byte[length]; + + in.read(buffer); + + token = EncodingUtils.getString(buffer, "UTF-8"); + + } catch (Exception e) { + e.printStackTrace(); + } + + if (!TextUtils.isEmpty(token)) { + AuthInfoManager.getInstance().setAuthInfo(token); + AuthInfoManager.getInstance().checkAuth(); + if (AuthInfoManager.getInstance().getAuthState()) { + Toast.makeText(ShortVideoActivity.this, "Auth Success", Toast.LENGTH_SHORT) + .show(); + } else { + Toast.makeText(ShortVideoActivity.this, "Auth Failed", Toast.LENGTH_SHORT) + .show(); + } + } else { + AuthInfoManager.getInstance().addAuthResultListener(new AuthInfoManager.CheckAuthResultListener() { + @Override + public void onAuthResult(int i) { + mMainHandler.post(new Runnable() { @Override public void run() { - if (!finalAuthResult) { - Toast.makeText(ShortVideoActivity.this, "get auth failed from app " + - "server", Toast.LENGTH_SHORT) + AuthInfoManager.getInstance().removeAuthResultListener(mCheckAuthResultListener); + if (AuthInfoManager.getInstance().getAuthState()) { + Toast.makeText(ShortVideoActivity.this, "Auth Success", Toast.LENGTH_SHORT) + .show(); + } else { + Toast.makeText(ShortVideoActivity.this, "Auth Failed", Toast.LENGTH_SHORT) .show(); - //鉴权失败,尝试3次 - if (mRetryCount < MAX_RETRY_COUNT) { - mRetryCount++; - checkAuth(); - } } } }); } - }; - } + }); + if (mAuthResponse == null) { + mAuthResponse = new HttpRequestTask.HttpResponseListener() { + @Override + public void onHttpResponse(int responseCode, String response) { + //params response + boolean authResult = false; + if (responseCode == 200) { + try { + JSONObject temp = new JSONObject(response); + JSONObject data = temp.getJSONObject("Data"); + int result = data.getInt("RetCode"); + if (result == 0) { + String authInfo = data.getString("Authorization"); + String date = data.getString("x-amz-date"); + //初始化鉴权信息 + AuthInfoManager.getInstance().setAuthInfo(authInfo, date); + //添加鉴权结果回调接口(不是必须) + AuthInfoManager.getInstance().addAuthResultListener(mCheckAuthResultListener); + //开始向KSServer申请鉴权 + AuthInfoManager.getInstance().checkAuth(); + authResult = true; + } else { + Log.e(TAG, "get auth failed from app server RetCode:" + result); + } + } catch (JSONException e) { + e.printStackTrace(); + Log.e(TAG, "get auth failed from app server json parse failed"); + } + } else { + Log.e(TAG, "get auth failed from app server responseCode:" + responseCode); + } - if (mAuthTask != null && mAuthTask.getStatus() != AsyncTask.Status.FINISHED) { - mAuthTask.cancel(true); - mAuthTask = null; + final boolean finalAuthResult = authResult; + runOnUiThread(new Runnable() { + @Override + public void run() { + if (!finalAuthResult) { + Toast.makeText(ShortVideoActivity.this, "get auth failed from app " + + "server", Toast.LENGTH_SHORT) + .show(); + //鉴权失败,尝试3次 + if (mRetryCount < MAX_RETRY_COUNT) { + mRetryCount++; + checkAuth(); + } + } + } + }); + } + }; + } + + if (mAuthTask != null && mAuthTask.getStatus() != AsyncTask.Status.FINISHED) { + mAuthTask.cancel(true); + mAuthTask = null; + } + //开启异步任务,向AppServer请求鉴权信息 + mAuthTask = new HttpRequestTask(mAuthResponse); + String url = AUTH_SERVER_URI + "?Pkg=" + getApplicationContext().getPackageName(); + Log.d(TAG, "request auth:" + url); + mAuthTask.execute(url); } - //开启异步任务,向AppServer请求鉴权信息 - mAuthTask = new HttpRequestTask(mAuthResponse); - String url = AUTH_SERVER_URI + "?Pkg=" + getApplicationContext().getPackageName(); - Log.d(TAG, "request auth:" + url); - mAuthTask.execute(url); } private AuthInfoManager.CheckAuthResultListener mCheckAuthResultListener = new AuthInfoManager diff --git a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/recordclip/RecordProgressController.java b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/recordclip/RecordProgressController.java index 1106bf8..40f77d9 100644 --- a/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/recordclip/RecordProgressController.java +++ b/demo/app/src/main/java/com/ksyun/media/shortvideo/demo/recordclip/RecordProgressController.java @@ -54,7 +54,7 @@ public RecordProgressController(RecordProgressView view, Chronometer cmt) { private class ChangeProgressRunnable implements Runnable { @Override public void run() { - if (getChronometerTime() >= RecordActivity.MAX_DURATION) { + if (getTotalRecordTime() >= RecordActivity.MAX_DURATION) { mProgressView.invalidate(); if (mIsRecording && mRecordingLengthChangedListener != null) { mRecordingLengthChangedListener.passMaxPoint(); @@ -83,6 +83,14 @@ public int getChronometerTime() { return curTime * 1000; } + private long getTotalRecordTime() { + long time = 0; + for (RecordClipModel clip : mProgressClipList) { + time += clip.timeInterval; + } + return time; + } + /** * 是否到达了最小录制时长 * diff --git a/demo/gradle/wrapper/gradle-wrapper.properties b/demo/gradle/wrapper/gradle-wrapper.properties index 75536f6..596049c 100644 --- a/demo/gradle/wrapper/gradle-wrapper.properties +++ b/demo/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,5 @@ -#Fri May 19 20:52:25 CST 2017 +#Thu May 18 16:03:35 CST 2017 + distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/docs/reference/com/ksyun/media/shortvideo/kit/KSYMergeKit.html b/docs/reference/com/ksyun/media/shortvideo/kit/KSYMergeKit.html index 712c235..6822000 100644 --- a/docs/reference/com/ksyun/media/shortvideo/kit/KSYMergeKit.html +++ b/docs/reference/com/ksyun/media/shortvideo/kit/KSYMergeKit.html @@ -592,7 +592,7 @@
interval | +I frame interval + | +
---|
set Constant Rate Factor
interval | +I frame interval + | +
---|
set Constant Rate Factor