In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "what is the method of fast access to SDK For Android". In the daily operation, I believe that many people have doubts about the method of fast access to SDK For Android. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what is the method of fast access to SDK For Android?" Next, please follow the editor to study!
Text
Since the access methods of the three versions are more or less the same, this article will focus on the access process of the basic version. The standard version and the professional version can be accessed based on the basic version. Later, only the access differences will be explained.
Access to the basic version 1. Introduction of aar and so
At present, the minimum requirements for aar platform version > = 4.3.First, download the corresponding version of SDK from the SDK download page. After decompression, copy the QuSdk-RC.aar under the libs folder to the libs folder in the Android project module, and copy the armeabi-v7a folder under the jniLibs folder to the libs folder as a whole.
After the copy is completed, the files of the directory are as follows:
Cdn.com/a3c99cdf2c604e073dabbb2aa90a1f05294c1fed.png ">
Then modify the build.gradle file under the main module of the Android project as follows:
Step1. Modify the source folder of jniLibs
Android {sourceSets.main {jniLibs.srcDir "libs"}}
Step2. Add the libs folder to the repository
Repositories {flatDir {dirs' libs'}}
Step3. Increase the dependency required by aar.
Dependencies {implementation (name: 'QuSdk-RC' Ext: 'aar') implementation' com.android.support:appcompat-v7:24.2.1' implementation 'com.android.support:design:24.2.1' implementation' com.google.code.findbugs:jsr305:3.0.0' implementation 'com.github.bumptech.glide:glide:3.7.0' implementation' pub.devrel:easypermissions:0.2.1' implementation 'com.squareup.okhttp3:okhttp:3.2.0' Implementation 'com.github.bumptech.glide:okhttp3-integration:1.4.0@aar' implementation' com.squareup.okio:okio:1.12.0' implementation 'com.google.code.gson:gson:2.8.0'}
If you encounter java.lang.NoSuchFieldError errors here, you can refer to the short video Android FAQ.
two。 Initialize SDK
Please choose the appropriate time to initialize SDK according to the specific project situation. The Demo project is initialized in the onCreate () method of Applicatioin.
Package me.bogerchan.alishortvideodemoimport android.app.Applicationimport com.aliyun.common.httpfinal.QupaiHttpFinal/** * Created by hb.chen on 2018-1-6. * / class MyApplication: Application () {override fun onCreate () {super.onCreate () System.loadLibrary ("QuCore-ThirdParty") System.loadLibrary ("QuCore") QupaiHttpFinal.getInstance (). InitOkHttpFinal ()} 3. Start writing your business logic
After the above process, the connection has actually been completed. At this time, you can refer to the documentation to start using various API directly, and the sample code is attached.
Package me.bogerchan.alishortvideodemoimport android.Manifestimport android.app.Activityimport android.content.Intentimport android.content.pm.PackageManagerimport android.os.Bundleimport android.support.v4.app.ActivityCompatimport android.support.v7.app.AppCompatActivityimport android.widget.Toastimport com.aliyun.demo.recorder.AliyunVideoRecorderimport com.aliyun.struct.common.VideoQualityimport com.aliyun.struct.snap.AliyunSnapVideoParamimport me.bogerchan.alishortvideodemo.basic.Rclass MainActivity: AppCompatActivity () {companion object {val REQUEST_CODE_RECORD_VIDEO = 1 val REQUEST_CODE_FOR_PERMISSION = 2} override fun onCreate (savedInstanceState: Bundle?) {super.onCreate (savedInstanceState) setContentView (R.layout.activity_main) findViewById (R.id.btn_start_record). SetOnClickListener {startRecordActivity ()} ActivityCompat.requestPermissions (this) ArrayOf (Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO) REQUEST_CODE_FOR_PERMISSION)} private fun startRecordActivity () {val recordParam = AliyunSnapVideoParam.Builder () .setResolutionMode (AliyunSnapVideoParam.RESOLUTION_720P) .setRatioMode (AliyunSnapVideoParam.RATIO_MODE_9_16) .setRecordMode (AliyunSnapVideoParam.RECORD_MODE_AUTO) .setNeedClip (true) .setMaxDuration (10000) .setMinDuration (2000) .setVideQuality (VideoQuality.HD) .setSortMode (AliyunSnapVideoParam.SORT_MODE_MERGE) .build () AliyunVideoRecorder.startRecordForResult (this) REQUEST_CODE_RECORD_VIDEO, recordParam)} override fun onActivityResult (requestCode: Int, resultCode: Int, data: Intent?) {super.onActivityResult (requestCode, resultCode, data) when (requestCode) {REQUEST_CODE_RECORD_VIDEO-> {if (resultCode = = Activity.RESULT_OK & & data! = null) {val type = data.getIntExtra (AliyunVideoRecorder.RESULT_TYPE 0) if (type = = AliyunVideoRecorder.RESULT_TYPE_CROP) {Toast.makeText (this, "Type is cropping", Toast.LENGTH_SHORT). Show ()} else if (type = = AliyunVideoRecorder.RESULT_TYPE_RECORD) {Toast.makeText (this, "File path is" > Standard version access 1. Introduction of aar and so
Compared with the basic version, the standard version introduced several more files when the so file was introduced, and the name of the aar file changed. The final copy result is as follows:
Build.gradle file modification is the same as the basic version access, except that the access aar file name needs to be replaced with the corresponding name of the standard version.
two。 Initialize SDK
Compared with the basic version, there are several more so to be loaded. As an optional feature, some so files decide whether to load according to the actual situation. For more information, please see the Aliyun short video SDK document. Reference to the connected Application file:
Package me.bogerchan.alishortvideodemoimport android.app.Applicationimport com.aliyun.common.httpfinal.QupaiHttpFinal/** * Created by hb.chen on 2018-1-6. * / class MyApplication: Application () {override fun onCreate () {super.onCreate () System.loadLibrary ("aliresample") System.loadLibrary ("live-openh364") System.loadLibrary ("QuCore-ThirdParty") System.loadLibrary ("QuCore") QupaiHttpFinal.getInstance (). InitOkHttpFinal ()} 3. Start writing your business logic
After the above process, the connection has actually been completed. At this time, you can refer to the documentation to start using various API directly, and the sample code is attached.
Package me.bogerchan.alishortvideodemoimport android.Manifestimport android.content.pm.PackageManagerimport android.opengl.GLSurfaceViewimport android.os.Bundleimport android.support.v4.app.ActivityCompatimport android.support.v7.app.AppCompatActivityimport android.widget.Toastimport com.aliyun.recorder.AliyunRecorderCreatorimport com.aliyun.struct.recorder.CameraTypeimport com.aliyun.struct.recorder.MediaInfoimport me.bogerchan.alishortvideodemo.std.Rclass MainActivity: AppCompatActivity () {companion object {val REQUEST_CODE_FOR_PERMISSION = 1} privateval mRecorder by lazy { AliyunRecorderCreator.getRecorderInstance (this)} private var mCameraType = CameraType.FRONT override fun onCreate (savedInstanceState: Bundle?) {super.onCreate (savedInstanceState) setContentView (R.layout.activity_main) ActivityCompat.requestPermissions (this ArrayOf (Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO) REQUEST_CODE_FOR_PERMISSION) initAliyunRecorder () findViewById (R.id.btn_start_record). SetOnClickListener {Toast.makeText (this, "start recording clip", Toast.LENGTH_SHORT). Show () mRecorder.startRecording ()} findViewById (R.id.btn_stop_record). SetOnClickListener {Toast.makeText (this, "stop recording clip" Toast.LENGTH_SHORT). Show () mRecorder.stopRecording ()} findViewById (R.id.btn_finish_record). SetOnClickListener {Toast.makeText (this, "end recording", Toast.LENGTH_SHORT). Show () mRecorder.finishRecording ()} findViewById (R.id.btn_change_camera_type). SetOnClickListener {Toast.makeText (this) "switch front and rear" Toast.LENGTH_SHORT) .show () mRecorder.switchCamera ()} override fun onStart () {super.onStart () mRecorder.startPreview ()} override fun onPause () {super.onPause () mRecorder.stopPreview ()} override fun onDestroy () {super.onDestroy () AliyunRecorderCreator.destroyRecorderInstance ()} Private fun initAliyunRecorder () {mRecorder.setDisplayView (findViewById (R.id.glsv_content) as GLSurfaceView) val mediaInfo = MediaInfo () mediaInfo.videoWidth = 800mediaInfo.videoHeight = 1200 mediaInfo.isHWAutoSize = true mRecorder.setMediaInfo (mediaInfo) mRecorder.setCamera (mCameraType) mRecorder.setOutputPath (externalCacheDir.absolutePath + "/ capture.mp4")} override fun onRequestPermissionsResult (requestCode: Int Permissions: Array, grantResults: IntArray) {super.onRequestPermissionsResult (requestCode, permissions, grantResults) when (requestCode) {REQUEST_CODE_FOR_PERMISSION-> {grantResults.forEach {if (it = = PackageManager.PERMISSION_DENIED) {Toast.makeText (this, "no permission" Show () finish () return@forEach} Professional version access 1. Introduction of aar and so
Compared with the basic version, the professional version introduced several more files when the so file was introduced, and the name of the aar file changed.
Build.gradle file modification is the same as the basic version access, except that the access aar file name needs to be replaced with the corresponding name of the professional version.
two。 Initialize SDK
Compared with the basic version, there are several more so to be loaded. As an optional feature, some so files decide whether to load according to the actual situation. For more information, please see the Aliyun short video SDK document. Reference to the connected Application file:
Package me.bogerchan.alishortvideodemoimport android.app.Applicationimport com.aliyun.common.httpfinal.QupaiHttpFinal/** * Created by hb.chen on 2018-1-6. * / class MyApplication: Application () {override fun onCreate () {super.onCreate () System.loadLibrary ("live-openh364") System.loadLibrary ("QuCore-ThirdParty") System.loadLibrary ("QuCore") System.loadLibrary ("FaceAREngine") System.loadLibrary ("AliFaceAREngine") QupaiHttpFinal.getInstance (). InitOkHttpFinal ()} 3 Start writing your business logic
After the above process, the connection has actually been completed. At this time, you can refer to the documentation to start using various API directly, and the sample code is attached.
Package me.bogerchan.alishortvideodemoimport android.Manifestimport android.content.pm.PackageManagerimport android.opengl.GLSurfaceViewimport android.os.Bundleimport android.support.v4.app.ActivityCompatimport android.support.v7.app.AppCompatActivityimport android.widget.Toastimport com.aliyun.recorder.AliyunRecorderCreatorimport com.aliyun.struct.recorder.CameraTypeimport com.aliyun.struct.recorder.MediaInfoimport me.bogerchan.alishortvideodemo.pro.Rclass MainActivity: AppCompatActivity () {companion object {val REQUEST_CODE_FOR_PERMISSION = 1} privateval mRecorder by lazy { AliyunRecorderCreator.getRecorderInstance (this)} private var mCameraType = CameraType.FRONT override fun onCreate (savedInstanceState: Bundle?) {super.onCreate (savedInstanceState) setContentView (R.layout.activity_main) ActivityCompat.requestPermissions (this ArrayOf (Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO) REQUEST_CODE_FOR_PERMISSION) initAliyunRecorder () findViewById (R.id.btn_start_record). SetOnClickListener {Toast.makeText (this, "start recording clip", Toast.LENGTH_SHORT). Show () mRecorder.startRecording ()} findViewById (R.id.btn_stop_record). SetOnClickListener {Toast.makeText (this, "stop recording clip" Toast.LENGTH_SHORT). Show () mRecorder.stopRecording ()} findViewById (R.id.btn_finish_record). SetOnClickListener {Toast.makeText (this, "end recording", Toast.LENGTH_SHORT). Show () mRecorder.finishRecording ()} findViewById (R.id.btn_change_camera_type). SetOnClickListener {Toast.makeText (this) "switch front and rear" Toast.LENGTH_SHORT) .show () mRecorder.switchCamera ()} override fun onStart () {super.onStart () mRecorder.startPreview ()} override fun onPause () {super.onPause () mRecorder.stopPreview ()} override fun onDestroy () {super.onDestroy () AliyunRecorderCreator.destroyRecorderInstance ()} Private fun initAliyunRecorder () {mRecorder.setDisplayView (findViewById (R.id.glsv_content) as GLSurfaceView) val mediaInfo = MediaInfo () mediaInfo.videoWidth = 800mediaInfo.videoHeight = 1200 mediaInfo.isHWAutoSize = true mRecorder.setMediaInfo (mediaInfo) mRecorder.setCamera (mCameraType) mRecorder.needFaceTrackInternal (true) mRecorder.setOutputPath (externalCacheDir.absolutePath + "/ capture.mp4")} override fun onRequestPermissionsResult (requestCode: Int Permissions: Array, grantResults: IntArray) {super.onRequestPermissionsResult (requestCode, permissions, grantResults) when (requestCode) {REQUEST_CODE_FOR_PERMISSION-> {grantResults.forEach {if (it = = PackageManager.PERMISSION_DENIED) {Toast.makeText (this, "no permission" Toast.LENGTH_SHORT) .show () finish () return@forEach}} this is the end of the study on "what is the method of fast access to SDK For Android". I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.