translate the note FilterActivity into English

translate the note FilterActivity into English
pull/166/head
xufulong 5 years ago
parent ef988b0d86
commit 3d25e20a94
  1. 19
      app/src/main/AndroidManifest.xml
  2. 19
      app/src/main/java/com/frank/ffmpeg/FFmpegApplication.java
  3. 50
      app/src/main/java/com/frank/ffmpeg/activity/FilterActivity.java
  4. 4
      app/src/main/res/layout/activity_filter.xml
  5. 14
      app/src/main/res/values/strings.xml

@ -13,6 +13,7 @@
<uses-feature android:name="android.hardware.camera.autofocus" />
<application
android:name=".FFmpegApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
@ -27,31 +28,31 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- 音频处理 -->
<!-- audio handle -->
<activity android:name=".activity.AudioHandleActivity" />
<!-- 音视频处理 -->
<!-- media handle -->
<activity android:name=".activity.MediaHandleActivity" />
<!-- 视频处理 -->
<!-- video handle -->
<activity android:name=".activity.VideoHandleActivity" />
<!-- 音视频解码播放 -->
<!-- media player -->
<activity
android:name=".activity.MediaPlayerActivity"
android:screenOrientation="landscape" />
<!-- 本地推流直播 -->
<!-- local pusher -->
<activity
android:name=".activity.PushActivity" />
<!-- 实时推流直播 -->
<!-- real time pusher -->
<activity
android:name=".activity.LiveActivity"
android:screenOrientation="portrait" />
<!-- 滤镜特效 -->
<!-- filter effect -->
<activity
android:name=".activity.FilterActivity"
android:screenOrientation="landscape" />
<!--视频播放拖动预览-->
<!-- video preview -->
<activity android:name=".activity.VideoPreviewActivity"
android:screenOrientation="portrait" />
<!--检测多媒体格式数据-->
<!-- probe media format -->
<activity android:name=".activity.ProbeFormatActivity"
android:screenOrientation="portrait" />
</application>

@ -0,0 +1,19 @@
package com.frank.ffmpeg;
import android.app.Application;
public class FFmpegApplication extends Application {
private static FFmpegApplication context;
@Override
public void onCreate() {
super.onCreate();
context = this;
}
public static FFmpegApplication getInstance() {
return context;
}
}

@ -4,8 +4,10 @@ import android.annotation.SuppressLint;
import android.os.Handler;
import android.os.Message;
import android.os.Bundle;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
@ -13,6 +15,7 @@ import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ToggleButton;
import com.frank.ffmpeg.FFmpegApplication;
import com.frank.ffmpeg.R;
import com.frank.ffmpeg.VideoPlayer;
import com.frank.ffmpeg.adapter.HorizontalAdapter;
@ -24,23 +27,21 @@ import java.util.Arrays;
import java.util.List;
/**
* 使用ffmpeg进行滤镜
* Using ffmpeg to filter
* Created by frank on 2018/6/5.
*/
public class FilterActivity extends BaseActivity implements SurfaceHolder.Callback {
//本地视频路径
private String videoPath = "";
private VideoPlayer videoPlayer;
private SurfaceView surfaceView;
private SurfaceHolder surfaceHolder;
//surface是否已经创建
private boolean surfaceCreated;
//是否正在播放
//is playing or not
private boolean isPlaying;
//滤镜数组
//the array of filter
private String[] filters = new String[]{
"lutyuv='u=128:v=128'",
"hue='h=60:s=-3'",
@ -52,20 +53,20 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
"vflip",
"unsharp"
};
//vflip is up and down, hflip is left and right
private String[] txtArray = new String[]{
"素描",
"鲜明",//hue
"暖蓝",
"边缘",
"九宫格",
"均衡",
"矩形",
"翻转",//vflip上下翻转,hflip是左右翻转
"锐化"
FFmpegApplication.getInstance().getString(R.string.filter_sketch),
FFmpegApplication.getInstance().getString(R.string.filter_distinct),
FFmpegApplication.getInstance().getString(R.string.filter_warming),
FFmpegApplication.getInstance().getString(R.string.filter_edge),
FFmpegApplication.getInstance().getString(R.string.filter_division),
FFmpegApplication.getInstance().getString(R.string.filter_equalize),
FFmpegApplication.getInstance().getString(R.string.filter_rectangle),
FFmpegApplication.getInstance().getString(R.string.filter_flip),
FFmpegApplication.getInstance().getString(R.string.filter_sharpening)
};
private HorizontalAdapter horizontalAdapter;
private RecyclerView recyclerView;
//是否播放音频
private boolean playAudio = true;
private ToggleButton btnSound;
private Button btnSelect;
@ -77,7 +78,7 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (msg.what == MSG_HIDE){//无操作5s后隐藏滤镜操作栏
if (msg.what == MSG_HIDE) { //after idle 5s, hide the controller view
recyclerView.setVisibility(View.GONE);
btnSound.setVisibility(View.GONE);
btnSelect.setVisibility(View.GONE);
@ -91,6 +92,7 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
mHandler.obtainMessage(MSG_HIDE).sendToTarget();
}
}
private HideRunnable hideRunnable;
@Override
@ -129,7 +131,6 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
initViewsWithClick(R.id.btn_select_file);
}
//注册监听器
private void registerLister() {
horizontalAdapter.setOnItemClickListener(new OnItemClickListener() {
@Override
@ -149,8 +150,8 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
public void onClick(View v) {
btnSelect.setVisibility(View.VISIBLE);
btnSound.setVisibility(View.VISIBLE);
recyclerView.setVisibility(View.VISIBLE);//按下SurfaceView,弹出滤镜操作栏
mHandler.postDelayed(hideRunnable, DELAY_TIME);//5s后发消息通知隐藏滤镜操作栏
recyclerView.setVisibility(View.VISIBLE);
mHandler.postDelayed(hideRunnable, DELAY_TIME);
}
});
@ -162,11 +163,14 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
});
}
/**
* switch filter
* @param position position in the array of filters
*/
private void doFilterPlay(final int position) {
new Thread(new Runnable() {
@Override
public void run() {
//切换播放
if (isPlaying) {
videoPlayer.again();
}
@ -176,7 +180,6 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
}).start();
}
//设置是否静音
private void setPlayAudio() {
playAudio = !playAudio;
videoPlayer.playAudio(playAudio);
@ -201,7 +204,7 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
protected void onDestroy() {
super.onDestroy();
isPlaying = false;
//暂时注释
//FIXME
// videoPlayer.release();
videoPlayer = null;
horizontalAdapter = null;
@ -217,9 +220,8 @@ public class FilterActivity extends BaseActivity implements SurfaceHolder.Callba
@Override
void onSelectedFile(String filePath) {
videoPath = filePath;
//选择滤镜模式
doFilterPlay(5);
//默认关闭声音
//sound off by default
btnSound.setChecked(true);
}

@ -20,8 +20,8 @@
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:textOff="@string/sound_close"
android:textOn="@string/sound_open"/>
android:textOff="@string/sound_off"
android:textOn="@string/sound_on"/>
<Button
android:id="@+id/btn_select_file"

@ -48,8 +48,8 @@
<string name="stop">停止</string>
<string name="mute">静音</string>
<string name="sound">声音</string>
<string name="sound_open">声音开</string>
<string name="sound_close">声音关</string>
<string name="sound_on">声音开</string>
<string name="sound_off">声音关</string>
<string name="video_sketch">素描</string>
<string name="video_hue">hue</string>
@ -73,4 +73,14 @@
<string name="converting_video">正在反转视频&#8230;</string>
<string name="tip_not_mp4_video">该视频不是mp4,无法进行moov前移操作</string>
<string name="filter_sketch">素描</string>
<string name="filter_distinct">鲜明</string>
<string name="filter_warming">暖蓝</string>
<string name="filter_edge">边缘</string>
<string name="filter_division">九宫格</string>
<string name="filter_equalize">均衡</string>
<string name="filter_rectangle">矩形</string>
<string name="filter_flip">翻转</string>
<string name="filter_sharpening">锐化</string>
</resources>

Loading…
Cancel
Save