Browse Source

解决编译问题

ykrank 5 years ago
parent
commit
cd46619a58

+ 0
- 1
android/build.gradle View File

45
 
45
 
46
 dependencies {
46
 dependencies {
47
     implementation fileTree(dir: 'libs', include: ['*.jar'])
47
     implementation fileTree(dir: 'libs', include: ['*.jar'])
48
-    implementation 'com.android.support:appcompat-v7:27.1.1'
49
     implementation 'com.android.support.constraint:constraint-layout:1.1.3'
48
     implementation 'com.android.support.constraint:constraint-layout:1.1.3'
50
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
49
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
51
 }
50
 }

android/src/main/java/com/fgodt/mixplayer/Core.java → android/src/main/java/com/shuangyubang/mofun_flutter_plugin_video/mixplayer/Core.java View File

1
-package com.fgodt.mixplayer;
1
+package com.shuangyubang.mofun_flutter_plugin_video.mixplayer;
2
 
2
 
3
 import android.util.Log;
3
 import android.util.Log;
4
 import android.view.Surface;
4
 import android.view.Surface;
5
-import android.view.SurfaceHolder;
6
-
7
-
8
-import java.util.Arrays;
9
 
5
 
10
 /**
6
 /**
11
  * Created by rt-zl on 2019/2/15.
7
  * Created by rt-zl on 2019/2/15.

android/src/main/java/com/fgodt/mixplayer/Player.java → android/src/main/java/com/shuangyubang/mofun_flutter_plugin_video/mixplayer/Player.java View File

1
-package com.fgodt.mixplayer;
1
+package com.shuangyubang.mofun_flutter_plugin_video.mixplayer;
2
 
2
 
3
 import android.content.Context;
3
 import android.content.Context;
4
 
4
 

android/src/main/java/com/fgodt/mixplayer/Render.java → android/src/main/java/com/shuangyubang/mofun_flutter_plugin_video/mixplayer/Render.java View File

1
-package com.fgodt.mixplayer;
1
+package com.shuangyubang.mofun_flutter_plugin_video.mixplayer;
2
 
2
 
3
 import android.content.Context;
3
 import android.content.Context;
4
 import android.media.AudioFormat;
4
 import android.media.AudioFormat;
28
 
28
 
29
     public int mixUpdateAudio(byte[] data, int size, double pts) {
29
     public int mixUpdateAudio(byte[] data, int size, double pts) {
30
         playTime = pts;
30
         playTime = pts;
31
-        synchronized (audioBuf) {
31
+        synchronized (audioBufLock) {
32
             if (audioBufLen - audioHas < size) {
32
             if (audioBufLen - audioHas < size) {
33
                 return -1;
33
                 return -1;
34
             }
34
             }
93
 
93
 
94
     AudioTrack audioTrack;
94
     AudioTrack audioTrack;
95
 
95
 
96
+    final Object audioBufLock = new Object();
96
     byte[] audioBuf;
97
     byte[] audioBuf;
97
     long totalAudioBuf;
98
     long totalAudioBuf;
98
     int audioHas;
99
     int audioHas;
105
 
106
 
106
     private void initAudioTrack() {
107
     private void initAudioTrack() {
107
         silencBuf = new byte[4096];
108
         silencBuf = new byte[4096];
108
-        audioBuf = new byte[audioBufLen];
109
+        synchronized (audioBufLock) {
110
+            audioBuf = new byte[audioBufLen];
111
+        }
109
         audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, asample,
112
         audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, asample,
110
                 AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT, audioBufLen, AudioTrack.MODE_STREAM);
113
                 AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT, audioBufLen, AudioTrack.MODE_STREAM);
111
         play = true;
114
         play = true;
112
-        new Thread(new Runnable() {
113
-            @Override
114
-            public void run() {
115
-                int wsize = 1024;
116
-                long posPre = 0;
117
-                boolean needUpdate = false;
118
-                int retryCount = 0;
119
-                while (play) {
120
-                    synchronized (audioBuf) {
121
-                        long pos = audioTrack.getPlaybackHeadPosition();
122
-                        // 16bit 2channels = 4 Byte
123
-                        pos *= 4;
124
-                        pos -= silenceLen;
125
-                        if (posPre != pos) {
126
-                            posPre = pos;
127
-                            retryCount = 0;
128
-                        } else {
129
-                            if (retryCount > 5)
130
-                                needUpdate = true;
131
-                            retryCount++;
115
+        new Thread(() -> {
116
+            int wsize = 1024;
117
+            long posPre = 0;
118
+            boolean needUpdate = false;
119
+            int retryCount = 0;
120
+            while (play) {
121
+                synchronized (audioBufLock) {
122
+                    long pos = audioTrack.getPlaybackHeadPosition();
123
+                    // 16bit 2channels = 4 Byte
124
+                    pos *= 4;
125
+                    pos -= silenceLen;
126
+                    if (posPre != pos) {
127
+                        posPre = pos;
128
+                        retryCount = 0;
129
+                    } else {
130
+                        if (retryCount > 5)
131
+                            needUpdate = true;
132
+                        retryCount++;
133
+                    }
134
+                    if (audioHas >= wsize && totalAudioBuf - pos < audioBufLen || pos <= 0 || needUpdate) {
135
+                        needUpdate = false;
136
+                        int len = audioBufLen - audioRPos;
137
+                        len = len > wsize ? wsize : len;
138
+                        int ret = audioTrack.write(audioBuf, audioRPos, len);
139
+                        audioRPos += ret;
140
+                        audioHas -= ret;
141
+                        totalAudioBuf += ret;
142
+                        if (audioRPos == audioBufLen) {
143
+                            audioRPos = 0;
132
                         }
144
                         }
133
-                        if (audioHas >= wsize && totalAudioBuf - pos < audioBufLen || pos <= 0 || needUpdate) {
134
-                            needUpdate = false;
135
-                            int len = audioBufLen - audioRPos;
136
-                            len = len > wsize ? wsize : len;
137
-                            int ret = audioTrack.write(audioBuf, audioRPos, len);
138
-                            audioRPos += ret;
139
-                            audioHas -= ret;
140
-                            totalAudioBuf += ret;
141
-                            if (audioRPos == audioBufLen) {
142
-                                audioRPos = 0;
145
+                    } else {
146
+                        //    if (pos == totalAudioBuf && audioHas < wsize){
147
+                        //        int c = audioTrack.write(silencBuf,0,2048);
148
+                        //        silenceLen +=c;
149
+                        //    }
150
+                    }
151
+                    if (ispause) {
152
+                        if (audioTrack.getPlayState() != AudioTrack.PLAYSTATE_PAUSED) {
153
+                            audioTrack.pause();
154
+                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
155
+                                audioTrack.setVolume(0);
156
+                            } else {
157
+                                audioTrack.setStereoVolume(0, 0);
143
                             }
158
                             }
144
-                        } else {
145
-                            //    if (pos == totalAudioBuf && audioHas < wsize){
146
-                            //        int c = audioTrack.write(silencBuf,0,2048);
147
-                            //        silenceLen +=c;
148
-                            //    }
149
                         }
159
                         }
150
-                        if (ispause) {
151
-                            if (audioTrack.getPlayState() != AudioTrack.PLAYSTATE_PAUSED) {
152
-                                audioTrack.pause();
153
-                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
154
-                                    audioTrack.setVolume(0);
155
-                                } else {
156
-                                    audioTrack.setStereoVolume(0, 0);
157
-                                }
158
-                            }
159
-                        } else {
160
-                            if (audioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) {
161
-                                audioTrack.play();
162
-                                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
163
-                                    audioTrack.setVolume(volume);
164
-                                } else {
165
-                                    audioTrack.setStereoVolume(volume, volume);
166
-                                }
160
+                    } else {
161
+                        if (audioTrack.getPlayState() != AudioTrack.PLAYSTATE_PLAYING) {
162
+                            audioTrack.play();
163
+                            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
164
+                                audioTrack.setVolume(volume);
165
+                            } else {
166
+                                audioTrack.setStereoVolume(volume, volume);
167
                             }
167
                             }
168
                         }
168
                         }
169
                     }
169
                     }
170
-                    try {
171
-                        sleep(3);
172
-                    } catch (Exception ex) {
173
-                    }
174
                 }
170
                 }
175
-                Log.d("mixplayer", "audio close");
171
+                try {
172
+                    sleep(3);
173
+                } catch (Exception ignored) {
174
+                }
176
             }
175
             }
176
+            Log.d("mixplayer", "audio close");
177
         }).start();
177
         }).start();
178
         audioTrack.play();
178
         audioTrack.play();
179
     }
179
     }

android/src/main/java/com/fgodt/mixplayer/VideoRender.java → android/src/main/java/com/shuangyubang/mofun_flutter_plugin_video/mixplayer/VideoRender.java View File

1
-package com.fgodt.mixplayer;
1
+package com.shuangyubang.mofun_flutter_plugin_video.mixplayer;
2
 
2
 
3
 
3
 
4
 
4
 

android/src/main/java/com/fgodt/mixplayer/mixPlayerCallBack.java → android/src/main/java/com/shuangyubang/mofun_flutter_plugin_video/mixplayer/mixPlayerCallBack.java View File

1
-package com.fgodt.mixplayer;
1
+package com.shuangyubang.mofun_flutter_plugin_video.mixplayer;
2
 
2
 
3
 public interface mixPlayerCallBack{
3
 public interface mixPlayerCallBack{
4
     public int mix_call(String name, byte[] data, int len);
4
     public int mix_call(String name, byte[] data, int len);

+ 2
- 4
android/src/main/kotlin/com/shuangyubang/mofun_flutter_plugin_video/MofunRealVideoView.kt View File

4
 import android.media.AudioFormat
4
 import android.media.AudioFormat
5
 import android.media.AudioRecord
5
 import android.media.AudioRecord
6
 import android.media.MediaRecorder
6
 import android.media.MediaRecorder
7
-import android.os.Environment
8
-import android.view.Gravity
9
 import android.view.View
7
 import android.view.View
10
 import android.widget.FrameLayout
8
 import android.widget.FrameLayout
11
 import android.widget.Toast
9
 import android.widget.Toast
12
-import com.fgodt.mixplayer.Player
13
-import com.fgodt.mixplayer.mixPlayerCallBack
10
+import com.shuangyubang.mofun_flutter_plugin_video.mixplayer.Player
11
+import com.shuangyubang.mofun_flutter_plugin_video.mixplayer.mixPlayerCallBack
14
 
12
 
15
 class MofunRealVideoView(val context: Context) : mixPlayerCallBack {
13
 class MofunRealVideoView(val context: Context) : mixPlayerCallBack {
16
 
14
 

+ 6
- 0
example/android/app/build.gradle View File

44
         versionCode flutterVersionCode.toInteger()
44
         versionCode flutterVersionCode.toInteger()
45
         versionName flutterVersionName
45
         versionName flutterVersionName
46
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
46
         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
47
+
47
     }
48
     }
48
 
49
 
49
     buildTypes {
50
     buildTypes {
59
     source '../..'
60
     source '../..'
60
 }
61
 }
61
 
62
 
63
+tasks.withType(JavaCompile) {
64
+    options.encoding = 'UTF-8'
65
+    options.compilerArgs << '-Xlint:unchecked,deprecation'
66
+}
67
+
62
 dependencies {
68
 dependencies {
63
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
69
     implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
64
     testImplementation 'junit:junit:4.12'
70
     testImplementation 'junit:junit:4.12'

+ 1
- 0
example/android/gradle.properties View File

1
 org.gradle.jvmargs=-Xmx1536M
1
 org.gradle.jvmargs=-Xmx1536M
2
+android.useAndroidX=true

+ 1
- 1
example/pubspec.lock View File

82
     source: hosted
82
     source: hosted
83
     version: "1.5.0"
83
     version: "1.5.0"
84
   permission_handler:
84
   permission_handler:
85
-    dependency: "direct main"
85
+    dependency: transitive
86
     description:
86
     description:
87
       name: permission_handler
87
       name: permission_handler
88
       url: "https://pub.flutter-io.cn"
88
       url: "https://pub.flutter-io.cn"

+ 0
- 1
example/pubspec.yaml View File

12
   # The following adds the Cupertino Icons font to your application.
12
   # The following adds the Cupertino Icons font to your application.
13
   # Use with the CupertinoIcons class for iOS style icons.
13
   # Use with the CupertinoIcons class for iOS style icons.
14
   cupertino_icons: ^0.1.2
14
   cupertino_icons: ^0.1.2
15
-  permission_handler: ^3.0.0
16
 
15
 
17
 dev_dependencies:
16
 dev_dependencies:
18
   flutter_test:
17
   flutter_test: