|
|
@@ -0,0 +1,618 @@
|
|
|
+package com.sheep.gamegroup.find.activity;
|
|
|
+
|
|
|
+import android.content.Context;
|
|
|
+import android.content.Intent;
|
|
|
+import android.graphics.Bitmap;
|
|
|
+import android.graphics.BitmapFactory;
|
|
|
+import android.media.MediaPlayer;
|
|
|
+import android.net.Uri;
|
|
|
+import android.os.Bundle;
|
|
|
+import android.support.annotation.Nullable;
|
|
|
+import android.support.v4.app.Fragment;
|
|
|
+import android.support.v7.widget.AppCompatButton;
|
|
|
+import android.util.Log;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.Button;
|
|
|
+import android.widget.LinearLayout;
|
|
|
+import android.widget.SeekBar;
|
|
|
+
|
|
|
+import com.kfzs.duanduan.utils.StatusBarUtils;
|
|
|
+import com.sheep.gamegroup.absBase.AbsObserver;
|
|
|
+import com.sheep.gamegroup.absBase.BaseContainerActivity;
|
|
|
+import com.sheep.gamegroup.find.bean.Filterble;
|
|
|
+import com.sheep.gamegroup.find.bean.IFilter;
|
|
|
+import com.sheep.gamegroup.find.bean.Size;
|
|
|
+import com.sheep.gamegroup.find.fragment.FgtChooseEditList;
|
|
|
+import com.sheep.gamegroup.model.entity.Video;
|
|
|
+import com.sheep.gamegroup.util.BitmapUtil;
|
|
|
+import com.sheep.gamegroup.util.DataUtil;
|
|
|
+import com.sheep.gamegroup.util.LogUtil;
|
|
|
+import com.sheep.gamegroup.util.TestUtil;
|
|
|
+import com.sheep.gamegroup.util.ViewUtil;
|
|
|
+import com.sheep.jiuyan.samllsheep.R;
|
|
|
+import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
+
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
+import org.wysaid.common.Common;
|
|
|
+import org.wysaid.myUtils.ImageUtil;
|
|
|
+import org.wysaid.nativePort.CGEFFmpegNativeLibrary;
|
|
|
+import org.wysaid.nativePort.CGEFrameRenderer;
|
|
|
+import org.wysaid.nativePort.CGENativeLibrary;
|
|
|
+import org.wysaid.view.VideoPlayerGLSurfaceView;
|
|
|
+
|
|
|
+import java.util.Locale;
|
|
|
+
|
|
|
+import butterknife.BindView;
|
|
|
+import io.reactivex.Observable;
|
|
|
+import io.reactivex.ObservableEmitter;
|
|
|
+import io.reactivex.ObservableOnSubscribe;
|
|
|
+import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
|
+import io.reactivex.schedulers.Schedulers;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by realicing on 2018/11/9.
|
|
|
+ * realicing@sina.com
|
|
|
+ * 编辑视频
|
|
|
+ */
|
|
|
+public class ActEditVideo extends BaseContainerActivity implements Filterble {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
+ StatusBarUtils.setTranslucent(this);
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected int getLayoutId() {
|
|
|
+ return R.layout.act_edit_video;
|
|
|
+ }
|
|
|
+
|
|
|
+ @BindView(R.id.videoGLSurfaceView)
|
|
|
+ VideoPlayerGLSurfaceView mPlayerView;
|
|
|
+
|
|
|
+ private Video data;
|
|
|
+
|
|
|
+ private String mCurrentConfig;
|
|
|
+ private float mIntensity = 1.0f;
|
|
|
+
|
|
|
+ public static final int REQUEST_CODE_PICK_VIDEO = 1;
|
|
|
+
|
|
|
+ private VideoPlayerGLSurfaceView.PlayCompletionCallback playCompletionCallback = new VideoPlayerGLSurfaceView.PlayCompletionCallback() {
|
|
|
+ @Override
|
|
|
+ public void playComplete(MediaPlayer player) {
|
|
|
+ Log.i(Common.LOG_TAG, "The video playing is over, restart...");
|
|
|
+ player.start();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean playFailed(MediaPlayer player, final int what, final int extra) {
|
|
|
+ if (TestUtil.isDev())
|
|
|
+ G.showToast(String.format(Locale.CHINA, "播放出错!错误码: %d, %d", what, extra));
|
|
|
+ else
|
|
|
+ G.showToast("播放出错,请稍候重试");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void initView() {
|
|
|
+ if (this instanceof BaseContainerActivity) {
|
|
|
+ super.initView();
|
|
|
+ }
|
|
|
+ data = DataUtil.getObject(getIntent(), Video.class);
|
|
|
+ mPlayerView.setZOrderOnTop(false);
|
|
|
+ mPlayerView.setZOrderMediaOverlay(true);
|
|
|
+
|
|
|
+
|
|
|
+ mPlayerView.setPlayerInitializeCallback(new VideoPlayerGLSurfaceView.PlayerInitializeCallback() {
|
|
|
+ @Override
|
|
|
+ public void initPlayer(final MediaPlayer player) {
|
|
|
+ //针对网络视频进行进度检查
|
|
|
+ player.setOnBufferingUpdateListener(new MediaPlayer.OnBufferingUpdateListener() {
|
|
|
+ @Override
|
|
|
+ public void onBufferingUpdate(MediaPlayer mp, int percent) {
|
|
|
+ Log.i(Common.LOG_TAG, "Buffer update: " + percent);
|
|
|
+ if (percent == 100) {
|
|
|
+ Log.i(Common.LOG_TAG, "缓冲完毕!");
|
|
|
+ player.setOnBufferingUpdateListener(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mPlayerView.setVideoUri(Uri.parse(data.getFilePath()), new VideoPlayerGLSurfaceView.PlayPreparedCallback() {
|
|
|
+ @Override
|
|
|
+ public void playPrepared(MediaPlayer player) {
|
|
|
+ Log.i(Common.LOG_TAG, "The video is prepared to play");
|
|
|
+ player.start();
|
|
|
+ }
|
|
|
+ }, playCompletionCallback);
|
|
|
+
|
|
|
+ LinearLayout menuLayout = findViewById(R.id.menuLinearLayout);
|
|
|
+ if (ViewUtil.isVisible(menuLayout)) {
|
|
|
+ loadTest(menuLayout);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //点击完成
|
|
|
+ public void onClickCommit(View view) {
|
|
|
+ showProgress(false);
|
|
|
+ Observable.create(new ObservableOnSubscribe<String>() {
|
|
|
+ @Override
|
|
|
+ public void subscribe(ObservableEmitter<String> emitter) throws Exception {
|
|
|
+ String srcFilPath = data.getFilePath();
|
|
|
+ String outputFilename = String.format(Locale.CHINA, "%s_%d_%f.mp4", srcFilPath.substring(0, srcFilPath.lastIndexOf(".")), mCurrentConfig.hashCode(), mIntensity);
|
|
|
+
|
|
|
+ Bitmap bmp = BitmapFactory.decodeResource(SheepApp.getInstance().getResources(), R.drawable.icon_lj);
|
|
|
+ Bitmap logo = BitmapUtil.createBigLogo(bmp, new Size().setWidth(G.WIDTH).setHeight(G.HEIGHT).setX(G.getRealPix(100)).setY(G.getRealPix(100)));
|
|
|
+ CGEFFmpegNativeLibrary.generateVideoWithFilter(outputFilename, srcFilPath, mCurrentConfig, mIntensity, logo, CGENativeLibrary.TextureBlendMode.CGE_BLEND_ADDREV, 1.0f, false);
|
|
|
+
|
|
|
+ LogUtil.println(ActEditVideo.class.getSimpleName(), "Done! The file is generated at: " + outputFilename);
|
|
|
+ emitter.onNext(outputFilename);
|
|
|
+ }
|
|
|
+ }).subscribeOn(Schedulers.io())
|
|
|
+ .observeOn(AndroidSchedulers.mainThread())
|
|
|
+ .subscribe(new AbsObserver<String>() {
|
|
|
+ @Override
|
|
|
+ public void onNext(String filePath) {
|
|
|
+ sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + filePath)));
|
|
|
+ data.setFilePath(filePath);
|
|
|
+ EventBus.getDefault().post(data);
|
|
|
+ ActEditVideo.this.finish();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onError(Throwable e) {
|
|
|
+ G.showToast(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onComplete() {
|
|
|
+ hideProgress();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置滤镜
|
|
|
+ @Override
|
|
|
+ public void setFilter(IFilter filter) {
|
|
|
+ if (mPlayerView != null && filter != null && filter.getConfig() != null) {
|
|
|
+ mCurrentConfig = filter.getConfig();
|
|
|
+ mPlayerView.setFilterWithConfig(mCurrentConfig);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setFilterIntensity(float intensity) {
|
|
|
+ if (mPlayerView != null) {
|
|
|
+ mIntensity = intensity;
|
|
|
+ mPlayerView.setFilterIntensity(mIntensity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //下面为测试代码
|
|
|
+
|
|
|
+ private void loadTest(LinearLayout menuLayout) {
|
|
|
+
|
|
|
+ mShapeBtn = findViewById(R.id.switchShapeBtn);
|
|
|
+
|
|
|
+ mShapeBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+
|
|
|
+ private boolean useMask = false;
|
|
|
+ Bitmap bmp;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ useMask = !useMask;
|
|
|
+ if (useMask) {
|
|
|
+ if (bmp == null)
|
|
|
+ bmp = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
|
|
|
+
|
|
|
+ if (bmp != null) {
|
|
|
+ mPlayerView.setMaskBitmap(bmp, false, new VideoPlayerGLSurfaceView.SetMaskBitmapCallback() {
|
|
|
+ @Override
|
|
|
+ public void setMaskOK(CGEFrameRenderer renderer) {
|
|
|
+// if(mPlayerView.isUsingMask()) {
|
|
|
+// renderer.setMaskFlipScale(1.0f, -1.0f);
|
|
|
+// }
|
|
|
+ Log.i(Common.LOG_TAG, "enable mask!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ mPlayerView.setMaskBitmap(null, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mTakeshotBtn = findViewById(R.id.takeShotBtn);
|
|
|
+
|
|
|
+ mTakeshotBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ mPlayerView.takeShot(new VideoPlayerGLSurfaceView.TakeShotCallback() {
|
|
|
+ @Override
|
|
|
+ public void takeShotOK(Bitmap bmp) {
|
|
|
+ if (bmp != null) {
|
|
|
+ String s = ImageUtil.saveBitmap(bmp);
|
|
|
+ ActEditVideo.this.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + s)));
|
|
|
+ } else {
|
|
|
+ Log.e(Common.LOG_TAG, "take shot failed!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ {
|
|
|
+ Button btn = new Button(this);
|
|
|
+ menuLayout.addView(btn);
|
|
|
+ btn.setAllCaps(false);
|
|
|
+ btn.setText("Last Recorded Video");
|
|
|
+ btn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ Uri lastVideoUri = Uri.parse(data.getFilePath());
|
|
|
+ mPlayerView.setVideoUri(lastVideoUri, new VideoPlayerGLSurfaceView.PlayPreparedCallback() {
|
|
|
+ @Override
|
|
|
+ public void playPrepared(MediaPlayer player) {
|
|
|
+ Log.i(Common.LOG_TAG, "The video is prepared to play");
|
|
|
+ player.start();
|
|
|
+ }
|
|
|
+ }, playCompletionCallback);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ String[] filePaths = {
|
|
|
+ data.getFilePath(),
|
|
|
+ "http://wge.wysaid.org/res/video/1.mp4",
|
|
|
+ "http://wysaid.org/p/test.mp4",
|
|
|
+ };
|
|
|
+
|
|
|
+ for (int i = 0; i != filePaths.length; ++i) {
|
|
|
+ MyVideoButton btn = new MyVideoButton(this);
|
|
|
+ btn.setText("Video" + i);
|
|
|
+ btn.videoUri = Uri.parse(filePaths[i]);
|
|
|
+ btn.videoView = mPlayerView;
|
|
|
+ btn.setOnClickListener(btn);
|
|
|
+ menuLayout.addView(btn);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i != EFFECT_CONFIGS.length; ++i) {
|
|
|
+ MyButtons button = new MyButtons(this, EFFECT_CONFIGS[i]);
|
|
|
+ button.setText("filter" + i);
|
|
|
+ button.setOnClickListener(mFilterSwitchListener);
|
|
|
+ menuLayout.addView(button);
|
|
|
+ }
|
|
|
+
|
|
|
+ mGalleryBtn = findViewById(R.id.galleryBtn);
|
|
|
+ mGalleryBtn.setOnClickListener(galleryBtnClickListener);
|
|
|
+
|
|
|
+ Button fitViewBtn = findViewById(R.id.fitViewBtn);
|
|
|
+ fitViewBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
+ boolean shouldFit = false;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ shouldFit = !shouldFit;
|
|
|
+ mPlayerView.setFitFullView(shouldFit);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ seekBarLl = findViewById(R.id.seekBarLl);
|
|
|
+ for (int i = 0; i < 6; i++) {
|
|
|
+ SeekBar sb = new SeekBar(SheepApp.getInstance());
|
|
|
+ sb.setMax(100);
|
|
|
+ sb.setProgress(50);
|
|
|
+ seekBarLl.addView(sb);
|
|
|
+ final int finalI = i;
|
|
|
+ sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onProgressChanged(SeekBar seekBar, int progress, boolean b) {
|
|
|
+ onSeek(finalI, progress);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStartTrackingTouch(SeekBar seekBar) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onStopTrackingTouch(SeekBar seekBar) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Button mShapeBtn;
|
|
|
+ Button mTakeshotBtn;
|
|
|
+ Button mGalleryBtn;
|
|
|
+ LinearLayout seekBarLl;
|
|
|
+
|
|
|
+ class MyVideoButton extends AppCompatButton implements View.OnClickListener {
|
|
|
+
|
|
|
+ Uri videoUri;
|
|
|
+ VideoPlayerGLSurfaceView videoView;
|
|
|
+
|
|
|
+ public MyVideoButton(Context context) {
|
|
|
+ super(context);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+
|
|
|
+ G.showToast("loading video: " + videoUri.getHost() + videoUri.getPath() + " If the video is from the internet, you may wait a while...");
|
|
|
+
|
|
|
+ videoView.setVideoUri(videoUri, new VideoPlayerGLSurfaceView.PlayPreparedCallback() {
|
|
|
+ @Override
|
|
|
+ public void playPrepared(MediaPlayer player) {
|
|
|
+ mPlayerView.post(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ G.showToast("Start playing " + videoUri.getHost() + videoUri.getPath());
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ player.start();
|
|
|
+ }
|
|
|
+ }, playCompletionCallback);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public static class MyButtons extends AppCompatButton {
|
|
|
+
|
|
|
+ public String filterConfig;
|
|
|
+
|
|
|
+ public MyButtons(Context context, String config) {
|
|
|
+ super(context);
|
|
|
+ filterConfig = config;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private int[] progresses = {50, 50, 50, 50, 50, 50};
|
|
|
+
|
|
|
+ private float getPercent(int index) {
|
|
|
+ return (progresses[index] - 50) / 50.0f;
|
|
|
+ }
|
|
|
+
|
|
|
+ private int getPercent(int index, int max) {
|
|
|
+ return progresses[index] * max / 100;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeekHsv(int index, int progress) {
|
|
|
+ progresses[index] = progress;//色调(H),饱和度(S),明度(V)
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@adjust hsv %.2f %.2f %.2f %.2f %.2f %.2f", getPercent(i++), getPercent(i++), getPercent(i++), getPercent(i++), getPercent(i++), getPercent(i)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeekHsl(int index, int progress) {
|
|
|
+ progresses[index] = progress;//0,0,0 色相(H)、饱和度(S)、明度(L)
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@adjust hsl %.2f %.2f %.2f", getPercent(i++), getPercent(i++), getPercent(i)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeekRgb(int index, int progress) {
|
|
|
+ progresses[index] = progress;//0,0,255,255 黑<白、反光<亮度
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@curve RGB(%d, %d)(%d, %d)", getPercent(i++, 255), getPercent(i++, 255), getPercent(i++, 255), getPercent(i, 255)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeekLevel(int index, int progress) {
|
|
|
+ progresses[index] = progress;//0,1,1
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@adjust level %.2f %.2f %.2f ", getPercent(i++), getPercent(i++), getPercent(i)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeekSaturation(int index, int progress) {
|
|
|
+ progresses[index] = progress;//1 饱和度
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@adjust saturation %.2f ", getPercent(0)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeek/*ColorBalance*/(int index, int progress) {
|
|
|
+ progresses[index] = progress;//0,0,0 红绿蓝
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@adjust colorbalance %.2f %.2f %.2f ", getPercent(i++), getPercent(i++), getPercent(i)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeekHaze(int index, int progress) {
|
|
|
+ progresses[index] = progress;
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@style haze %.2f %.2f %.2f %.2f %.2f ", getPercent(i++), getPercent(i++), getPercent(i++), getPercent(i++), getPercent(i)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private static String[] TYPES = {"overlay", "colordodge", "pinlight", "ol", "screen"};
|
|
|
+
|
|
|
+ private void onSeekPixBlend(int index, int progress) {
|
|
|
+ progresses[index] = progress;
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@adjust saturation %.2f @pixblend %s %.2f %.2f %.2f %d ", getPercent(i++), TYPES[progresses[1] / 20 % TYPES.length], getPercent(i++), getPercent(i++), getPercent(i++), getPercent(i, 40)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeekCurve(int index, int progress) {
|
|
|
+ progresses[index] = progress;
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@curve R(%d, %d)(%d, %d)(%d, %d) ", getPercent(i++, 255), getPercent(i++, 255), getPercent(i++, 255), getPercent(i++, 255), getPercent(i++, 255), getPercent(i++, 255)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void onSeekBeautify(int index, int progress) {
|
|
|
+ progresses[index] = progress;
|
|
|
+ int i = 0;
|
|
|
+ mPlayerView.setFilterWithConfig(String.format(Locale.CHINA, "@beautify face %d %d, %d ", getPercent(i++, 2), getPercent(i++, 1000), getPercent(i++, 1000)));
|
|
|
+ }
|
|
|
+
|
|
|
+ private View.OnClickListener mFilterSwitchListener = new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ MyButtons btn = (MyButtons) v;
|
|
|
+ mPlayerView.setFilterWithConfig(btn.filterConfig);
|
|
|
+ mCurrentConfig = btn.filterConfig;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ android.view.View.OnClickListener galleryBtnClickListener = new android.view.View.OnClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(final android.view.View view) {
|
|
|
+ Intent videoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
+ videoPickerIntent.setType("video/*");
|
|
|
+ startActivityForResult(videoPickerIntent, REQUEST_CODE_PICK_VIDEO);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ public void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
|
|
|
+ switch (requestCode) {
|
|
|
+ case REQUEST_CODE_PICK_VIDEO:
|
|
|
+ if (resultCode == RESULT_OK) {
|
|
|
+
|
|
|
+ mPlayerView.setVideoUri(data.getData(), new VideoPlayerGLSurfaceView.PlayPreparedCallback() {
|
|
|
+ @Override
|
|
|
+ public void playPrepared(MediaPlayer player) {
|
|
|
+ Log.i(Common.LOG_TAG, "The video is prepared to play");
|
|
|
+ player.start();
|
|
|
+ }
|
|
|
+ }, playCompletionCallback);
|
|
|
+ }
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onPause() {
|
|
|
+ super.onPause();
|
|
|
+ Log.i(VideoPlayerGLSurfaceView.LOG_TAG, "activity onPause...");
|
|
|
+ mPlayerView.release();
|
|
|
+ mPlayerView.onPause();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onResume() {
|
|
|
+ super.onResume();
|
|
|
+
|
|
|
+ mPlayerView.onResume();
|
|
|
+ }
|
|
|
+
|
|
|
+ public static final String EFFECT_CONFIGS[] = {
|
|
|
+ "",
|
|
|
+ "@curve RGB(0,255)(255,0) @style cm mapping0.jpg 80 80 8 3", // ASCII art (字符画效果)
|
|
|
+ "@beautify face 1 480 640", //Beautify
|
|
|
+ "@adjust lut edgy_amber.png",
|
|
|
+ "@adjust lut filmstock.png",
|
|
|
+ "@adjust lut foggy_night.png",
|
|
|
+ "@adjust lut late_sunset.png",
|
|
|
+ "@adjust lut soft_warming.png",
|
|
|
+ "@adjust lut wildbird.png",
|
|
|
+ "#unpack @blur lerp 0.75", //can adjust blur intensity
|
|
|
+ "@blur lerp 1", //can adjust blur mix
|
|
|
+ "#unpack @dynamic wave 1", //can adjust speed
|
|
|
+ "@dynamic wave 0.5", //can adjust wave mix
|
|
|
+ "#unpack @style sketch 0.9",
|
|
|
+ "#unpack @krblend sr hehe.jpg 100 ",
|
|
|
+ "#unpack @krblend ol hehe.jpg 100",
|
|
|
+ "#unpack @krblend add hehe.jpg 100",
|
|
|
+ "#unpack @krblend darken hehe.jpg 100",
|
|
|
+ "@beautify bilateral 100 3.5 2 ",
|
|
|
+ "@style crosshatch 0.01 0.003 ",
|
|
|
+ "@style edge 1 2 ",
|
|
|
+ "@style edge 1 2 @curve RGB(0, 255)(255, 0) ",
|
|
|
+ "@style edge 1 2 @curve RGB(0, 255)(255, 0) @adjust saturation 0 @adjust level 0.33 0.71 0.93 ",
|
|
|
+ "@adjust level 0.31 0.54 0.13 ",
|
|
|
+ "#unpack @style emboss 1 2 2 ",//浮雕
|
|
|
+ "@style halftone 1.2 ",//半色调
|
|
|
+ "@vigblend overlay 255 0 0 255 100 0.12 0.54 0.5 0.5 3 ",
|
|
|
+ "@curve R(0, 0)(63, 101)(200, 84)(255, 255)G(0, 0)(86, 49)(180, 183)(255, 255)B(0, 0)(19, 17)(66, 41)(97, 92)(137, 156)(194, 211)(255, 255)RGB(0, 0)(82, 36)(160, 183)(255, 255) ",
|
|
|
+ "@adjust exposure 0.98 ",//暴光
|
|
|
+ "@adjust shadowhighlight -200 200 ",//阴影高亮
|
|
|
+ "@adjust sharpen 10 1.5 ",//锐化
|
|
|
+ "@adjust colorbalance 0.99 0.52 -0.31 ",//色平衡
|
|
|
+ "@adjust level 0.66 0.23 0.44 ",
|
|
|
+ "@style min",
|
|
|
+ "@style max",
|
|
|
+ "@style haze 0.5 -0.14 1 0.8 1 ",
|
|
|
+ "@curve R(0, 0)(71, 74)(164, 165)(255, 255) @pixblend screen 0.94118 0.29 0.29 1 20",//415
|
|
|
+ "@curve G(0, 0)(144, 166)(255, 255) @pixblend screen 0.94118 0.29 0.29 1 20",//416
|
|
|
+ "@curve B(0, 0)(68, 72)(149, 184)(255, 255) @pixblend screen 0.94118 0.29 0.29 1 20",//417
|
|
|
+ "@curve R(0, 0)(71, 74)(164, 165)(255, 255) @pixblend overlay 0.357 0.863 0.882 1 40",//418
|
|
|
+ "@curve R(0, 0)(96, 61)(154, 177)(255, 255) @pixblend overlay 0.357 0.863 0.882 1 40",//419
|
|
|
+ "@curve R(0, 0)(152, 183)(255, 255)G(0, 0)(161, 133)(255, 255) @pixblend overlay 0.357 0.863 0.882 1 40",//420
|
|
|
+ "@curve R(0, 0)(149, 145)(255, 255)G(0, 0)(149, 145)(255, 255)B(0, 0)(149, 145)(255, 255) @pixblend colordodge 0.937 0.482 0.835 1 20",//421
|
|
|
+ "@curve G(0, 0)(101, 127)(255, 255) @pixblend colordodge 0.937 0.482 0.835 1 20",//422
|
|
|
+ "@curve B(0, 0)(70, 87)(140, 191)(255, 255) @pixblend pinlight 0.247 0.49 0.894 1 20",//423
|
|
|
+ "@adjust saturation 0.7 @pixblend screen 0.8112 0.243 1 1 40",//425
|
|
|
+ "@adjust saturation 0.7 @pixblend screen 1 0.243 0.69 1 30",//426
|
|
|
+
|
|
|
+ "@curve R(0, 0)(71, 74)(164, 165)(255, 255) @pixblend screen 0.94118 0.29 0.29 1 20",//415
|
|
|
+ "@curve G(0, 0)(144, 166)(255, 255) @pixblend screen 0.94118 0.29 0.29 1 20",//416
|
|
|
+ "@curve B(0, 0)(68, 72)(149, 184)(255, 255) @pixblend screen 0.94118 0.29 0.29 1 20",//417
|
|
|
+ "@curve R(0, 0)(71, 74)(164, 165)(255, 255) @pixblend overlay 0.357 0.863 0.882 1 40",//418
|
|
|
+ "@curve R(0, 0)(96, 61)(154, 177)(255, 255) @pixblend overlay 0.357 0.863 0.882 1 40",//419
|
|
|
+ "@curve R(0, 0)(152, 183)(255, 255)G(0, 0)(161, 133)(255, 255) @pixblend overlay 0.357 0.863 0.882 1 40",//420
|
|
|
+ "@curve R(0, 0)(149, 145)(255, 255)G(0, 0)(149, 145)(255, 255)B(0, 0)(149, 145)(255, 255) @pixblend colordodge 0.937 0.482 0.835 1 20",//421
|
|
|
+ "@curve G(0, 0)(101, 127)(255, 255) @pixblend colordodge 0.937 0.482 0.835 1 20",//422
|
|
|
+ "@curve B(0, 0)(70, 87)(140, 191)(255, 255) @pixblend pinlight 0.247 0.49 0.894 1 20",//423
|
|
|
+ "@adjust saturation 0.7 @pixblend screen 0.8112 0.243 1 1 40",//425
|
|
|
+ "@adjust saturation 0.7 @pixblend screen 1 0.243 0.69 1 30",//426
|
|
|
+
|
|
|
+ "@curve R(0, 0)(117, 95)(155, 171)(179, 225)(255, 255)G(0, 0)(94, 66)(155, 176)(255, 255)B(0, 0)(48, 59)(141, 130)(255, 224)",//5
|
|
|
+ "@curve R(0, 0)(69, 63)(105, 138)(151, 222)(255, 255)G(0, 0)(67, 51)(135, 191)(255, 255)B(0, 0)(86, 76)(150, 212)(255, 255)",//6
|
|
|
+ "@curve R(0, 0)(43, 77)(56, 104)(100, 166)(255, 255)G(0, 0)(35, 53)(255, 255)B(0, 0)(110, 123)(255, 212)",//7
|
|
|
+ "@curve R(0, 0)(35, 71)(153, 197)(255, 255)G(0, 15)(16, 36)(109, 132)(255, 255)B(0, 23)(181, 194)(255, 230)",//8
|
|
|
+ "@curve R(15, 0)(92, 133)(255, 234)G(0, 20)(105, 128)(255, 255)B(0, 0)(120, 132)(255, 214)",//9
|
|
|
+ "@curve R(0, 4)(255, 244)G(0, 0)(255, 255)B(0, 84)(255, 194)",//10
|
|
|
+ "@curve R(48, 56)(82, 129)(130, 206)(214, 255)G(7, 37)(64, 111)(140, 190)(232, 220)B(2, 97)(114, 153)(229, 172)",//11
|
|
|
+ "@curve R(39, 0)(93, 61)(130, 136)(162, 193)(208, 255)G(41, 0)(92, 61)(128, 133)(164, 197)(200, 250)B(0, 23)(125, 127)(255, 230)",//12
|
|
|
+ "@curve R(40, 162)(108, 186)(142, 208)(193, 227)(239, 249)G(13, 7)(72, 87)(124, 150)(197, 206)(255, 255)B(8, 22)(57, 97)(112, 147)(184, 204)(255, 222)",//13
|
|
|
+ "@curve R(18, 0)(67, 63)(104, 152)(128, 255)G(23, 4)(87, 106)(132, 251)B(17, 0)(67, 63)(108, 174)(128, 251)",//14
|
|
|
+ "@curve R(5, 49)(85, 173)(184, 249)G(23, 35)(65, 76)(129, 145)(255, 199)B(74, 69)(158, 107)(255, 126)",//15
|
|
|
+ "@adjust hsv -0.7 -0.7 0.5 -0.7 -0.7 0.5 @pixblend ol 0.243 0.07059 0.59215 1 25",//17
|
|
|
+ "@adjust hsv -0.7 0.5 -0.7 -0.7 -0.7 0.5 @pixblend ol 0.07059 0.60391 0.57254 1 25",//18
|
|
|
+ "@adjust hsv -0.7 0.5 -0.7 -0.7 0 0 @pixblend ol 0.2941 0.55292 0.06665 1 25",//19
|
|
|
+ "@adjust hsv -0.8 0 -0.8 -0.8 0.5 -0.8 @pixblend ol 0.78036 0.70978 0.09018 1 28",//20
|
|
|
+
|
|
|
+ "@adjust hsv -0.4 -0.64 -1.0 -0.4 -0.88 -0.88 @curve R(0, 0)(119, 160)(255, 255)G(0, 0)(83, 65)(163, 170)(255, 255)B(0, 0)(147, 131)(255, 255)",//22
|
|
|
+ "@adjust hsv -0.5 -0.5 -0.5 -0.5 -0.5 -0.5 @curve R(0, 0)(129, 148)(255, 255)G(0, 0)(92, 77)(175, 189)(255, 255)B(0, 0)(163, 144)(255, 255)",//23
|
|
|
+ "@adjust hsv 0.3 -0.5 -0.3 0 0.35 -0.2 @curve R(0, 0)(111, 163)(255, 255)G(0, 0)(72, 56)(155, 190)(255, 255)B(0, 0)(103, 70)(212, 244)(255, 255)",//24
|
|
|
+ "@curve R(40, 40)(86, 148)(255, 255)G(0, 28)(67, 140)(142, 214)(255, 255)B(0, 100)(103, 176)(195, 174)(255, 255) @adjust hsv 0.32 0 -0.5 -0.2 0 -0.4",//25
|
|
|
+ "@curve R(4, 35)(65, 82)(117, 148)(153, 208)(206, 255)G(13, 5)(74, 78)(109, 144)(156, 201)(250, 250)B(6, 37)(93, 104)(163, 184)(238, 222)(255, 237) @adjust hsv -0.2 -0.2 -0.44 -0.2 -0.2 -0.2",//26
|
|
|
+ "@adjust hsv -1 -1 -1 -1 -1 -1",//27
|
|
|
+ "@colormul mat 0.34 0.48 0.22 0.34 0.48 0.22 0.34 0.48 0.22 @curve R(0, 29)(20, 48)(83, 103)(164, 166)(255, 239)G(0, 30)(30, 61)(66, 94)(151, 160)(255, 241)B(2, 48)(82, 93)(166, 143)(255, 199)",//119
|
|
|
+ "@colormul mat 0.34 0.48 0.22 0.34 0.48 0.22 0.34 0.48 0.22 @curve R(0, 0)(9, 10)(47, 38)(87, 69)(114, 92)(134, 116)(175, 167)(218, 218)(255, 255)G(40, 0)(45, 14)(58, 34)(74, 55)(125, 118)(192, 205)(255, 255)B(0, 0)(15, 16)(37, 31)(71, 55)(108, 88)(159, 151)(204, 201)(255, 255)",//120
|
|
|
+ "@curve R(3, 0)(23, 29)(83, 116)(167, 206)(255, 255)G(5, 0)(56, 64)(160, 189)(255, 255)B(3, 0)(48, 49)(142, 167)(248, 255)",//160
|
|
|
+ "@curve R(15, 0)(45, 37)(92, 103)(230, 255)G(19, 0)(34, 22)(138, 158)(228, 252)B(19, 0)(74, 63)(159, 166)(230, 255)",//161
|
|
|
+ "@curve R(0, 4)(39, 103)(134, 223)(242, 255)G(0, 3)(31, 85)(68, 155)(131, 255)(219, 255)B(0, 3)(42, 110)(114, 207)(255, 255)",//162
|
|
|
+ "@curve R(17, 0)(37, 18)(75, 52)(238, 255)G(16, 0)(53, 32)(113, 92)(236, 255)B(16, 0)(80, 57)(171, 164)(235, 255)",//163
|
|
|
+ "@curve R(33, 0)(70, 32)(146, 143)(185, 204)(255, 255)G(22, 0)(103, 71)(189, 219)(255, 252)B(10, 0)(54, 29)(93, 66)(205, 220)(255, 255)",//164
|
|
|
+ "@curve R(4, 4)(38, 38)(146, 146)(201, 202)(255, 255)G(0, 0)(80, 74)(192, 187)(255, 255)B(0, 0)(58, 58)(183, 184)(255, 255)",//165
|
|
|
+ "@curve R(5, 8)(36, 51)(115, 145)(201, 220)(255, 255)G(6, 9)(67, 83)(169, 190)(255, 255)B(3, 3)(55, 60)(177, 190)(255, 255)",//166
|
|
|
+ "@curve R(14, 0)(51, 42)(135, 138)(191, 202)(234, 255)G(11, 6)(78, 77)(178, 185)(242, 250)B(11, 0)(22, 10)(72, 60)(171, 162)(217, 209)(255, 255)",//167
|
|
|
+ "@curve R(9, 0)(26, 7)(155, 108)(194, 159)(255, 253)G(9, 0)(50, 19)(218, 194)(255, 255)B(0, 0)(29, 9)(162, 116)(218, 194)(255, 255)",//168
|
|
|
+ "@curve R(0, 0)(69, 93)(126, 160)(210, 232)(255, 255)G(0, 0)(36, 47)(135, 169)(250, 254)B(0, 0)(28, 30)(107, 137)(147, 206)(255, 255)",//169
|
|
|
+ "@curve R(2, 2)(16, 30)(72, 112)(135, 185)(252, 255)G(2, 1)(30, 42)(55, 84)(157, 207)(238, 249)B(1, 0)(26, 17)(67, 106)(114, 165)(231, 250)",//170
|
|
|
+ "@curve R(16, 0)(60, 45)(124, 124)(214, 255)G(18, 2)(91, 81)(156, 169)(213, 255)B(16, 0)(85, 74)(158, 171)(211, 255) @curve R(17, 0)(144, 150)(214, 255)G(16, 0)(61, 47)(160, 172)(215, 255)B(21, 2)(131, 135)(213, 255)",//171
|
|
|
+ "@curve R(0, 0)(120, 96)(165, 255)G(90, 0)(131, 145)(172, 255)B(77, 0)(165, 167)(255, 255)",//172
|
|
|
+ "@curve R(9, 0)(49, 62)(124, 155)(218, 255)G(10, 0)(30, 33)(137, 169)(223, 255)B(10, 0)(37, 45)(96, 122)(150, 182)(221, 255)",//173
|
|
|
+ "@curve R(81, 3)(161, 129)(232, 253)G(91, 0)(164, 136)(255, 225)B(76, 0)(196, 162)(255, 225)",//174
|
|
|
+ "@curve R(0, 0)(135, 147)(255, 255)G(0, 0)(135, 147)(255, 255)B(0, 0)(135, 147)(255, 255) @adjust saturation 0.71 @adjust brightness -0.05 @curve R(19, 0)(45, 36)(88, 90)(130, 125)(200, 170)(255, 255)G(18, 0)(39, 26)(71, 74)(147, 160)(255, 255)B(0, 0)(77, 58)(136, 132)(255, 204)",//300
|
|
|
+ "@adjust saturation 0 @curve R(9, 13)(37, 13)(63, 23)(81, 43)(91, 58)(103, 103)(159, 239)(252, 242)G(3, 20)(29, 20)(56, 19)(77, 37)(107, 108)(126, 184)(137, 217)(150, 248)(182, 284)(255, 255)B(45, 17)(78, 51)(96, 103)(131, 202)(255, 255)",//301
|
|
|
+ "@curve R(42, 2)(53, 52)(80, 102)(100, 123)(189, 196)(255, 255)G(55, 74)(75, 98)(95, 114)(177, 197)(203, 212)(221, 220)(229, 234)(240, 249)B(0, 132)(81, 188)(180, 251)",//303
|
|
|
+ "@adjust saturation 0 @curve R(0, 68)(10, 72)(42, 135)(72, 177)(98, 201)(220, 255)G(0, 29)(12, 30)(57, 127)(119, 203)(212, 255)(254, 239)B(0, 36)(54, 118)(66, 141)(119, 197)(155, 215)(255, 254)",//304
|
|
|
+ "@curve R(0, 64)(16, 13)(58, 128)(108, 109)(162, 223)(255, 255)G(0, 30)(22, 35)(42, 58)(56, 86)(70, 119)(130, 184)(189, 212)B(6, 36)(76, 157)(107, 192)(173, 229)(255, 255)", //306
|
|
|
+ "@vigblend mix 10 10 30 255 91 0 1.0 0.5 0.5 3 @curve R(0, 31)(35, 75)(81, 139)(109, 174)(148, 207)(255, 255)G(0, 24)(59, 88)(105, 146)(130, 171)(145, 187)(180, 214)(255, 255)B(0, 96)(63, 130)(103, 157)(169, 194)(255, 255)",
|
|
|
+ "@adjust saturation 0 @curve R(0, 49)(16, 44)(34, 56)(74, 120)(120, 185)(151, 223)(255, 255)G(0, 46)(34, 73)(85, 129)(111, 164)(138, 192)(170, 215)(255, 255)B(0, 77)(51, 101)(105, 143)(165, 182)(210, 213)(250, 229)",
|
|
|
+ "@adjust saturation 0 @adjust level 0 0.83921 0.8772",
|
|
|
+ "@adjust hsl 0.02 -0.31 -0.17 @curve R(0, 28)(23, 45)(117, 148)(135, 162)G(0, 8)(131, 152)(255, 255)B(0, 17)(58, 80)(132, 131)(127, 131)(255, 225)"
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected Fragment initFragment() {
|
|
|
+ return new FgtChooseEditList();
|
|
|
+ }
|
|
|
+}
|