Browse Source

尝试整合video到flutter

ykrank 5 years ago
parent
commit
ce735d6cb7

+ 49
- 0
android/src/main/kotlin/com/shuangyubang/mofun_flutter_plugin_video/MofunRealVideoView.kt View File

@@ -0,0 +1,49 @@
1
+package com.shuangyubang.mofun_flutter_plugin_video
2
+
3
+import android.content.Context
4
+import android.view.Gravity
5
+import android.view.View
6
+import android.widget.EditText
7
+import android.widget.FrameLayout
8
+import android.widget.LinearLayout
9
+import com.fgodt.mixplayer.Player
10
+import com.fgodt.mixplayer.mixPlayerCallBack
11
+
12
+class MofunRealVideoView(val context: Context) : mixPlayerCallBack {
13
+
14
+    private var trueView:FrameLayout? = null
15
+
16
+    fun getView(): View? {
17
+        synchronized(MofunRealVideoView::class) {
18
+            if (trueView == null){
19
+                initView()
20
+            }
21
+        }
22
+        return trueView
23
+    }
24
+
25
+    private fun initView(){
26
+        trueView = FrameLayout(context)
27
+        val params = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
28
+                FrameLayout.LayoutParams.WRAP_CONTENT)
29
+        params.gravity = Gravity.TOP
30
+        params.height = 1080 * 9 / 16
31
+        val mixplayer = Player(context)
32
+        mixplayer.setMixCall(this)
33
+        mixplayer.addMixSource("mix1", 0.0, -1.0)
34
+        mixplayer.addMixSource("silence", 0.0, -1.0)
35
+        // mixplayer.selectAudioSource("silence");
36
+        // mixplayer.selectAudioSource("mix1");
37
+
38
+        trueView?.addView(mixplayer, params)
39
+
40
+    }
41
+
42
+    override fun mix_call(name: String?, data: ByteArray?, len: Int): Int {
43
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
44
+    }
45
+
46
+    override fun closeMsg(msg: String?) {
47
+        TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
48
+    }
49
+}

+ 2
- 2
example/android/app/build.gradle View File

@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
26 26
 apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 27
 
28 28
 android {
29
-    compileSdkVersion 28
29
+    compileSdkVersion 27
30 30
 
31 31
     sourceSets {
32 32
         main.java.srcDirs += 'src/main/kotlin'
@@ -40,7 +40,7 @@ android {
40 40
         // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
41 41
         applicationId "com.shuangyubang.mofun_flutter_plugin_video_example"
42 42
         minSdkVersion 16
43
-        targetSdkVersion 28
43
+        targetSdkVersion 27
44 44
         versionCode flutterVersionCode.toInteger()
45 45
         versionName flutterVersionName
46 46
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"