48 Star 420 Fork 149

AnJoiner / FFmpegCommand

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
KFFmpegCodecActivity.kt 3.41 KB
一键复制 编辑 原始数据 按行查看 历史
AnJoiner 提交于 2020-11-22 20:03 . 调试beta版本
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)
}
}
}
Android
1
https://gitee.com/anjoiner/FFmpegCommand.git
git@gitee.com:anjoiner/FFmpegCommand.git
anjoiner
FFmpegCommand
FFmpegCommand
master

搜索帮助