-
Notifications
You must be signed in to change notification settings - Fork 155
/
KFFmpegCodecActivity.kt
115 lines (96 loc) · 3.41 KB
/
KFFmpegCodecActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package com.coder.ffmpegtest.ui
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.text.method.ScrollingMovementMethod
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.coder.ffmpeg.annotation.CodecAttribute
import com.coder.ffmpeg.jni.FFmpegCommand
import com.coder.ffmpegtest.R
import com.coder.ffmpegtest.model.CommandBean
import com.coder.ffmpegtest.ui.adapter.FFmpegCommandAdapter
import java.util.ArrayList
/**
*
* @author: AnJoiner
* @datetime: 20-11-14
*/
class KFFmpegCodecActivity : AppCompatActivity(){
private var mRecyclerView: RecyclerView? = null
private var tvContent: TextView? = null
private var mAdapter: FFmpegCommandAdapter? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_ffmpeg_codec)
init()
}
private fun init() {
initView()
initData()
initListener()
}
private fun initView() {
mRecyclerView = findViewById(R.id.rv)
tvContent = findViewById(R.id.tv_content)
tvContent?.movementMethod = ScrollingMovementMethod.getInstance();
}
private fun initData() {
val commands = this.resources.getStringArray(R.array.codecs)
val beans: MutableList<CommandBean> = ArrayList()
for (i in commands.indices) {
beans.add(CommandBean(commands[i], i))
}
mAdapter = FFmpegCommandAdapter(beans)
mRecyclerView!!.layoutManager = GridLayoutManager(this, 3)
mRecyclerView!!.adapter = mAdapter
}
private fun initListener() {
mAdapter!!.setItemClickListener (object : FFmpegCommandAdapter.ItemClickListener {
override fun itemClick(id: Int) {
when (id) {
0 -> enCodecs()
1 -> deCodecs()
2 -> audioCodecs()
3 -> audioDeCodecs()
4 -> videoCodecs()
5 -> videoDeCodecs()
6 -> otherCodecs()
7 -> otherDeCodecs()
}
}
})
}
private fun enCodecs(){
tvContent?.text = FFmpegCommand.getSupportCodec(CodecAttribute.ENCODE)
}
private fun deCodecs(){
tvContent?.text = FFmpegCommand.getSupportCodec(CodecAttribute.DECODE)
}
private fun audioCodecs(){
tvContent?.text = FFmpegCommand.getSupportCodec(CodecAttribute.ENCODE_AUDIO)
}
private fun audioDeCodecs(){
tvContent?.text = FFmpegCommand.getSupportCodec(CodecAttribute.DECODE_AUDIO)
}
private fun videoCodecs(){
tvContent?.text = FFmpegCommand.getSupportCodec(CodecAttribute.ENCODE_VIDEO)
}
private fun videoDeCodecs(){
tvContent?.text = FFmpegCommand.getSupportCodec(CodecAttribute.DECODE_VIDEO)
}
private fun otherCodecs(){
tvContent?.text = FFmpegCommand.getSupportCodec(CodecAttribute.ENCODE_OTHER)
}
private fun otherDeCodecs(){
tvContent?.text = FFmpegCommand.getSupportCodec(CodecAttribute.DECODE_OTHER)
}
companion object{
fun start(context: Context){
val intent = Intent(context,KFFmpegCodecActivity::class.java)
context.startActivity(intent)
}
}
}