Skip to content

Commit

Permalink
Merge pull request #69 from KevinHuo/dev
Browse files Browse the repository at this point in the history
release v1.10.0
  • Loading branch information
geeklok authored Mar 26, 2018
2 parents 0e95cb2 + 3a11bd4 commit d104db9
Show file tree
Hide file tree
Showing 59 changed files with 2,929 additions and 21 deletions.
7 changes: 4 additions & 3 deletions PLDroidShortVideoDemo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId "com.qiniu.pili.droid.shortvideo.demo"
minSdkVersion 18
targetSdkVersion 25
versionCode 14
versionName "1.9.0"
versionCode 15
versionName "1.10.0"
multiDexEnabled true
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
ndk {
Expand All @@ -32,7 +32,7 @@ android {

dependencies {
compile 'com.qiniu:qiniu-android-sdk:7.3.10'
compile files('libs/pldroid-shortvideo-1.9.0.jar')
compile files('libs/pldroid-shortvideo-1.10.0.jar')
compile files('libs/pldroid-player-2.0.5.jar')
compile files('libs/EasyAR.jar')
compile files('libs/EasyAR3D.jar')
Expand All @@ -52,4 +52,5 @@ dependencies {
compile files('libs/TuSDKFace-1.0.0.jar')
compile files('libs/TuSDKVideo-1.11.0.jar')
compile files('libs/universal-image-loader-1.9.4.jar')
compile 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:0.10.6'
}
Binary file not shown.
Binary file not shown.
19 changes: 15 additions & 4 deletions PLDroidShortVideoDemo/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />

<application
android:name=".tusdk.TuApplication"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:name=".tusdk.TuApplication"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".activity.MainActivity">
Expand All @@ -27,8 +27,7 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activity.VideoRecordActivity" />
<activity android:name=".activity.VideoRecordActivity" />
<activity
android:name=".activity.AudioRecordActivity"
android:screenOrientation="portrait" />
Expand Down Expand Up @@ -72,11 +71,23 @@
<activity
android:name=".activity.DraftBoxActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"/>
android:theme="@style/AppTheme" />
<activity
android:name=".activity.VideoDubActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
<activity
android:name=".activity.VideoDivideActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
<activity
android:name=".activity.TransitionMakeActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
<activity
android:name=".activity.VideoFrameActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme" />
<activity android:name=".activity.WebViewActivity" />
</application>

Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ private void initview() {
}

private String prepareUrl() {
String timeStamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
String fileName = "EasyAR_Recording_" + timeStamp + ".mp4";
String timestamp = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss").format(new Date());
String fileName = "EasyAR_Recording_" + timestamp + ".mp4";
File folder = new File(Config.VIDEO_STORAGE_DIR + "ArMovies");
if (!folder.exists())
folder.mkdirs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ public void onClickAR(View v) {
}
}

public void onClickTransitionMake(View v) {
if (isPermissionOK()) {
jumpToActivity(VideoDivideActivity.class);
}
}

public void onClickDraftBox(View v) {
if (isPermissionOK()) {
jumpToActivity(DraftBoxActivity.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
package com.qiniu.pili.droid.shortvideo.demo.activity;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.qiniu.pili.droid.shortvideo.PLVideoEncodeSetting;
import com.qiniu.pili.droid.shortvideo.PLVideoSaveListener;
import com.qiniu.pili.droid.shortvideo.demo.R;
import com.qiniu.pili.droid.shortvideo.demo.transition.Transition0;
import com.qiniu.pili.droid.shortvideo.demo.transition.Transition1;
import com.qiniu.pili.droid.shortvideo.demo.transition.Transition2;
import com.qiniu.pili.droid.shortvideo.demo.transition.Transition3;
import com.qiniu.pili.droid.shortvideo.demo.transition.Transition4;
import com.qiniu.pili.droid.shortvideo.demo.transition.Transition5;
import com.qiniu.pili.droid.shortvideo.demo.transition.TransitionBase;
import com.qiniu.pili.droid.shortvideo.demo.utils.ToastUtils;
import com.qiniu.pili.droid.shortvideo.demo.view.CustomProgressDialog;
import com.qiniu.pili.droid.shortvideo.demo.view.TransitionEditView;

import java.lang.reflect.Constructor;

import static com.qiniu.pili.droid.shortvideo.demo.activity.VideoFrameActivity.DATA_EXTRA_PATH;
import static com.qiniu.pili.droid.shortvideo.demo.utils.Config.VIDEO_STORAGE_DIR;

public class TransitionMakeActivity extends Activity {
private static final String TAG = "TransitionMakeActivity";

private static String[] TRANSITION_TITLE = {
"大标题", "章节", "简约", "引用", "标题与副标题", "片尾"
};
private static Class[] TRANSITION_CLASS = {
Transition0.class, Transition1.class, Transition2.class, Transition3.class, Transition4.class, Transition5.class
};

private RecyclerView mTransListView;
private CustomProgressDialog mProcessingDialog;

private TransitionBase[] mTransitions = new TransitionBase[6];
private TransitionBase mCurTransition;
private TransitionEditView mTransEditView;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_transition);

initTransitions();

mTransListView = (RecyclerView) findViewById(R.id.recycler_transition);
mTransEditView = (TransitionEditView) findViewById(R.id.transition_edit_view);

LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
mTransListView.setLayoutManager(layoutManager);
mTransListView.setAdapter(new TransListAdapter());

//consumed the event
mTransEditView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});

mProcessingDialog = new CustomProgressDialog(this);
mProcessingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
mCurTransition.cancelSave();
}
});
}

private void initTransitions() {
final PLVideoEncodeSetting setting = new PLVideoEncodeSetting(TransitionMakeActivity.this);
setting.setEncodingSizeLevel(PLVideoEncodeSetting.VIDEO_ENCODING_SIZE_LEVEL.VIDEO_ENCODING_SIZE_LEVEL_720P_3);
for (int i = 0; i < mTransitions.length; i++) {
final ViewGroup viewGroup = (ViewGroup) findViewById(getResources().getIdentifier("transition_container" + i, "id", getPackageName()));
final int index = i;
viewGroup.post(new Runnable() {
@Override
public void run() {
try {
Constructor constructor = TRANSITION_CLASS[index].getConstructor(ViewGroup.class, PLVideoEncodeSetting.class);
TransitionBase transition = (TransitionBase) constructor.newInstance(viewGroup, setting);

mTransitions[index] = transition;

//default show first transition
if (index == 0) {
transition.setVisibility(View.VISIBLE);
mCurTransition = transition;
mTransEditView.setTransition(mCurTransition);
} else {
transition.setVisibility(View.INVISIBLE);
}
} catch (Exception e) {
e.printStackTrace();
ToastUtils.s(TransitionMakeActivity.this, "Can not init Transition : " + "Transition" + index);
}
}
});
}
}

public void onBackClicked(View view) {
finish();
}

public void onSaveClicked(View view) {
mProcessingDialog.show();
String path = VIDEO_STORAGE_DIR + "pl-transition-" + System.currentTimeMillis() + ".mp4";

mCurTransition.save(path, new PLVideoSaveListener() {
@Override
public void onSaveVideoSuccess(final String destFile) {
Log.i(TAG, "save success: " + destFile);
runOnUiThread(new Runnable() {
@Override
public void run() {
mProcessingDialog.dismiss();

Intent intent = new Intent();
intent.putExtra(DATA_EXTRA_PATH, destFile);
setResult(VideoFrameActivity.TRANSITION_REQUEST_CODE, intent);
finish();
}
});
}

@Override
public void onSaveVideoFailed(int errorCode) {
}

@Override
public void onSaveVideoCanceled() {
}

@Override
public void onProgressUpdate(final float percentage) {
runOnUiThread(new Runnable() {
@Override
public void run() {
mProcessingDialog.setProgress((int) (100 * percentage));
}
});
}
});
}

public void onEditClicked(View view) {
mTransEditView.setVisibility(View.VISIBLE);
}

@Override
protected void onDestroy() {
super.onDestroy();
for (int i = 0; i < mTransitions.length; i++) {
mTransitions[i].destroy();
}
}

@Override
public void onBackPressed() {
if (mTransEditView.getVisibility() == View.VISIBLE) {
mTransEditView.setVisibility(View.GONE);
} else {
finish();
}
}

private class TransViewHolder extends RecyclerView.ViewHolder {
public TextView mTitle;
public View mItemView;

public TransViewHolder(View itemView) {
super(itemView);
mItemView = itemView;
mTitle = (TextView) itemView.findViewById(R.id.title_text);
}
}

private class TransListAdapter extends RecyclerView.Adapter<TransViewHolder> {
private View mSelectedView;

@Override
public TransViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
View contactView = inflater.inflate(R.layout.item_transition_selector, parent, false);
TransViewHolder viewHolder = new TransViewHolder(contactView);
return viewHolder;
}

@Override
public void onBindViewHolder(final TransViewHolder holder, final int position) {
holder.mTitle.setText(TRANSITION_TITLE[position]);
holder.mItemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mSelectedView != null) {
mSelectedView.setSelected(false);
}
holder.mItemView.setSelected(true);
mSelectedView = holder.mItemView;

for (int i = 0; i < mTransitions.length; i++) {
mTransitions[i].setVisibility(View.GONE);
}
mTransitions[position].setVisibility(View.VISIBLE);
mTransitions[position].play();
mCurTransition = mTransitions[position];
mTransEditView.setTransition(mCurTransition);
}
});
}

@Override
public int getItemCount() {
return TRANSITION_TITLE.length;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,14 @@ public void onClickCompose(View v) {
ToastUtils.s(this, "请先添加至少 2 个视频");
return;
}
mProcessingDialog.show();
PLVideoEncodeSetting setting = new PLVideoEncodeSetting(this);
setting.setEncodingSizeLevel(getEncodingSizeLevel(mEncodingSizeLevelSpinner.getSelectedItemPosition()));
setting.setEncodingBitrate(getEncodingBitrateLevel(mEncodingBitrateLevelSpinner.getSelectedItemPosition()));
mShortVideoComposer.composeVideos(videos, Config.COMPOSE_FILE_PATH, setting, mVideoSaveListener);
if (mShortVideoComposer.composeVideos(videos, Config.COMPOSE_FILE_PATH, setting, mVideoSaveListener)) {
mProcessingDialog.show();
} else {
ToastUtils.s(this, "开始拼接失败!");
}
}

private PLVideoSaveListener mVideoSaveListener = new PLVideoSaveListener() {
Expand Down
Loading

0 comments on commit d104db9

Please sign in to comment.