Skip to content

Commit

Permalink
Android VideoFeeder updates
Browse files Browse the repository at this point in the history
  • Loading branch information
orenagiv committed Jun 10, 2022
1 parent 93ba802 commit a5881cc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -144,14 +144,14 @@ Below the `<application>` tag and above the `<activity>` tag, add the following

##### 3. Update android/app/build.gradle
Open the android/app/build.grade file and update the following:
- Set defaultConfig parameters with minSdkVersion 19 and targetSdkVersion 30 (the Target SDK to 30 and not 31, as it caused issues with the Manifest merge).
- Set defaultConfig parameters with minSdkVersion 24 and targetSdkVersion 30 (the Target SDK to 30 and not 31, as it caused issues with the Manifest merge).
Also, **add and make sure multiDexEnabled is set to TRUE**:
```
android {
...
defaultConfig {
...
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 30
...
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Expand Up @@ -44,7 +44,7 @@ android {
}

defaultConfig {
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 30
multiDexEnabled true
// ndk {
Expand Down
Expand Up @@ -22,7 +22,6 @@ import dji.sdk.base.BaseComponent
import dji.sdk.base.BaseProduct
import dji.sdk.base.BaseProduct.ComponentKey
import dji.sdk.camera.VideoFeeder
import dji.sdk.camera.VideoFeeder.VideoDataListener
import dji.sdk.flightcontroller.FlightController
import dji.sdk.media.DownloadListener
import dji.sdk.media.MediaFile
Expand Down Expand Up @@ -71,7 +70,7 @@ class DjiPlugin: FlutterPlugin, Messages.DjiHostApi, ActivityAware {
private var drone: Aircraft? = null
private var droneCurrentLocation: LocationCoordinate3D? = null // Note: this is different from DJI SDK iOS where CLLocation.coordinate is used (LocationCoordinate3D in dji-android is the same as CLLocation.coordinate in dji-ios).
private var mediaFileList: MutableList<MediaFile> = ArrayList<MediaFile>()
private var videoDataListener: VideoDataListener? = null
private var videoDataListener: VideoFeeder.VideoDataListener? = null

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
Messages.DjiHostApi.setup(flutterPluginBinding.binaryMessenger, this)
Expand Down Expand Up @@ -751,14 +750,20 @@ class DjiPlugin: FlutterPlugin, Messages.DjiHostApi, ActivityAware {
/** Video Feed Methods **/

override fun videoFeedStart() {
videoDataListener = VideoDataListener { bytes, _ ->
_fltSendVideo(bytes)
if (videoDataListener == null) {
videoDataListener = VideoFeeder.VideoDataListener { bytes, _ ->
_fltSendVideo(bytes)
}
}
videoDataListener?.let {
VideoFeeder.getInstance()?.primaryVideoFeed?.addVideoDataListener(it)
}
VideoFeeder.getInstance().primaryVideoFeed.addVideoDataListener(videoDataListener!!)
}

override fun videoFeedStop() {
VideoFeeder.getInstance().primaryVideoFeed.removeVideoDataListener(videoDataListener)
videoDataListener?.let {
VideoFeeder.getInstance()?.primaryVideoFeed?.removeVideoDataListener(it)
}
}

}
Expand Down
4 changes: 2 additions & 2 deletions doc/api/index.html
Expand Up @@ -185,14 +185,14 @@ <h5 id="2-updated-the-android-manifest-xml">2. Updated the Android Manifest XML<
<h5 id="3-update-androidappbuildgradle">3. Update android/app/build.gradle</h5>
<p>Open the android/app/build.grade file and update the following:</p>
<ul>
<li>Set defaultConfig parameters with minSdkVersion 19 and targetSdkVersion 30 (the Target SDK to 30 and not 31, as it caused issues with the Manifest merge).<br>
<li>Set defaultConfig parameters with minSdkVersion 24 and targetSdkVersion 30 (the Target SDK to 30 and not 31, as it caused issues with the Manifest merge).<br>
Also, <strong>add and make sure multiDexEnabled is set to TRUE</strong>:</li>
</ul>
<pre class="language-dart"><code>android {
...
defaultConfig {
...
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 30
...

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Expand Up @@ -44,7 +44,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "cloud.dragonx.plugin.flutter.djiExample"
minSdkVersion 21
minSdkVersion 24
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down

0 comments on commit a5881cc

Please sign in to comment.