MSDK V5使用FPVWidget,始终不显示画面,配置程序是否如下

已完成

评论

3 条评论

  • DJI Developer Support
    在按照教程导入UXSDK模块之后,可以参考下面的MainActivity.java文件去显示画面: package com.dji.myapplication import android.opengl.Visibility import android.os.Bundle import android.util.Log import android.view.View import android.view.View.INVISIBLE import android.view.View.VISIBLE import androidx.appcompat.app.AppCompatActivity import dji.v5.common.error.IDJIError import dji.v5.common.register.DJISDKInitEvent import dji.v5.common.video.stream.StreamSource import dji.v5.manager.SDKManager import dji.v5.manager.datacenter.video.VideoStreamManager import dji.v5.manager.interfaces.SDKManagerCallback import dji.v5.ux.core.widget.fpv.* class MainActivity : AppCompatActivity() { private val TAG = "myApp" protected var primaryFpvWidget: FPVWidget? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) registerApp() primaryFpvWidget = findViewById(R.id.widget_primary_fpv) **primaryFpvWidget?.visibility = INVISIBLE** } private fun registerApp() { SDKManager.getInstance().init(this, object : SDKManagerCallback { override fun onRegisterSuccess() { Log.i(TAG, "myApp onRegisterSuccess") } override fun onRegisterFailure(error: IDJIError) { Log.i(TAG, "myApp onRegisterFailure") } override fun onProductDisconnect(productId: Int) { Log.i(TAG, "myApp onProductDisconnect") } override fun onProductConnect(productId: Int) { Log.i(TAG, "myApp onProductConnect") VideoStreamManager.getInstance().addStreamSourcesListener() { it?.let { if(it.size > 0) **primaryFpvWidget?.visibility = VISIBLE** } } } override fun onProductChanged(productId: Int) { Log.i(TAG, "myApp onProductChanged") } override fun onInitProcess(event: DJISDKInitEvent, totalProcess: Int) { Log.i(TAG, "myApp onInitProcess") if (event == DJISDKInitEvent.INITIALIZE_COMPLETE) { Log.i(TAG, "myApp start registerApp") SDKManager.getInstance().registerApp() } } override fun onDatabaseDownloadProgress(current: Long, total: Long) { Log.i(TAG, "myApp onDatabaseDownloadProgress") } }) } } 我在项目里导入了UXSDK模块,然后在MainActivity里配置FPVWidget。需要关注的是加粗的部分。效果如下: ![](https://djisdksupport.zendesk.com/attachments/token/peQyTXseUBqeFPNajF7kPZy3v/?name=image.png)
    0
    评论操作 固定链接
  • 123

    👍

    0
    评论操作 固定链接
  • DJI Developer Support
    很高兴可以帮助到你,祝你生活愉快。
    0
    评论操作 固定链接

请先登录再写评论。