Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions .idea/libraries/Flutter_Plugins.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/runConfigurations/example_lib_main_dart.xml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/vcs.xml

This file was deleted.

13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# 使用Flutter实现 仿微信录音的插件
插件支持android 和IOS

更新Android的build.gradle,修复RecordWav和AndroidAudioConverter库的问题

-------
插件提供的功能
Expand Down Expand Up @@ -34,18 +35,8 @@
引入方式1(引入最新的版本)
flutter_plugin_record:
git:
url: https://github.com/yxwandroid/flutter_plugin_record.git
url: https://github.com/szuwest/flutter_plugin_record.git

引入方式2 (引入指定某次commit)
flutter_plugin_record:
git:
url: https://github.com/yxwandroid/flutter_plugin_record.git
ref: 29c02b15835907879451ad9f8f88c357149c6085

引入方式3 (引入Flutter仓库的library)

dependencies:
flutter_plugin_record: ^1.0.1



Expand Down
11 changes: 6 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@ group 'record.wilson.flutter.com.flutter_plugin_record'
version '1.0-SNAPSHOT'

buildscript {
// ext.kotlin_version = '1.2.71'
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'

repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down Expand Up @@ -44,7 +43,9 @@ android {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.github.shaoshuai904:RecordWav:1.0.2'
implementation 'com.github.shaoshuai904:RecordWav:1.2.1'
// api(name:'RecordWav-1.0.2', ext: 'aar')
implementation "androidx.appcompat:appcompat:1.0.0"
implementation 'com.github.adrielcafe:AndroidAudioConverter:0.0.8'
// implementation 'com.github.adrielcafe:AndroidAudioConverter:0.0.8'
implementation 'com.github.szuwest:AndroidAudioConverter:0.0.9-2'
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class FlutterPluginRecordPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
@JvmStatic
fun registerWith(registrar: Registrar) {
val plugin = initPlugin(registrar.messenger())
plugin.activity=registrar.activity()
plugin.activity= registrar.activity()!!
registrar.addRequestPermissionsResultListener(plugin)
}

Expand All @@ -63,7 +63,7 @@ class FlutterPluginRecordPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
}
}
override fun onAttachedToEngine(binding: FlutterPlugin.FlutterPluginBinding) {
val methodChannel = createMethodChannel(binding.binaryMessenger)
val methodChannel = createMethodChannel(binding.binaryMessenger)
methodChannel.setMethodCallHandler(this)
channel=methodChannel
}
Expand Down Expand Up @@ -321,10 +321,10 @@ class FlutterPluginRecordPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
}
}
AndroidAudioConverter.with(activity.applicationContext)
.setFile(recordFile)
.setFormat(AudioFormat.MP3)
.setCallback(callback)
.convert()
.setFile(recordFile)
.setFormat(AudioFormat.MP3)
.setCallback(callback)
.convert()

}else{
val _id = call.argument<String>("id")
Expand Down Expand Up @@ -402,10 +402,10 @@ class FlutterPluginRecordPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
}
}
AndroidAudioConverter.with(activity.applicationContext)
.setFile(recordFile)
.setFormat(AudioFormat.MP3)
.setCallback(callback)
.convert()
.setFile(recordFile)
.setFormat(AudioFormat.MP3)
.setCallback(callback)
.convert()

}else{
val _id = call.argument<String>("id")
Expand Down Expand Up @@ -462,9 +462,9 @@ class FlutterPluginRecordPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar


// 权限监听回调
override fun onRequestPermissionsResult(p0: Int, p1: Array<out String>?, p2: IntArray?): Boolean {
override fun onRequestPermissionsResult(p0: Int, p1: Array<out String>, p2: IntArray): Boolean {
if (p0 == 1) {
if (p2?.get(0) == PackageManager.PERMISSION_GRANTED) {
if (p2[0] == PackageManager.PERMISSION_GRANTED) {
// initRecord()
return true
} else {
Expand All @@ -478,6 +478,6 @@ class FlutterPluginRecordPlugin : FlutterPlugin, MethodCallHandler, ActivityAwar
return false
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private void initVoicePath() {
private void initRecorder() {
recorder = MsRecorder.wav(
new File(voicePath),
new AudioRecordConfig.Default(),
new AudioRecordConfig(),
new PullTransport.Default()
.setOnAudioChunkPulledListener(new PullTransport.OnAudioChunkPulledListener() {
@Override
Expand Down
2 changes: 1 addition & 1 deletion example/.flutter-plugins-dependencies
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_plugin_record","path":"/Users/wilson/aochuang/FlutterDemo/flutter_plugin_record/","dependencies":[]},{"name":"path_provider","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.24/","dependencies":[]},{"name":"shared_preferences","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+4/","dependencies":[]}],"android":[{"name":"flutter_plugin_record","path":"/Users/wilson/aochuang/FlutterDemo/flutter_plugin_record/","dependencies":[]},{"name":"path_provider","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/path_provider-1.6.24/","dependencies":[]},{"name":"shared_preferences","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences-0.5.12+4/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/path_provider_macos-0.0.4+6/","dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_macos-0.0.1+11/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-0.0.1+2/","dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-0.0.2+4/","dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-0.0.4+3/","dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-0.0.1+3/","dependencies":["path_provider_windows"]}],"web":[{"name":"shared_preferences_web","path":"/Users/wilson/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-0.1.2+7/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_record","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2021-03-24 11:27:57.607425","version":"2.0.3"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_plugin_record","path":"/Users/kk/Documents/workspace/flutter_plugin_record/","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/path_provider_ios-2.0.11/","native_build":true,"dependencies":[]},{"name":"shared_preferences_ios","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_ios-2.1.1/","native_build":true,"dependencies":[]}],"android":[{"name":"flutter_plugin_record","path":"/Users/kk/Documents/workspace/flutter_plugin_record/","native_build":true,"dependencies":[]},{"name":"path_provider_android","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/path_provider_android-2.0.21/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_android-2.0.14/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/path_provider_macos-2.0.6/","native_build":true,"dependencies":[]},{"name":"shared_preferences_macos","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_macos-2.0.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/path_provider_linux-2.1.7/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_linux-2.1.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"path_provider_windows","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/path_provider_windows-2.1.3/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_windows-2.1.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"shared_preferences_web","path":"/Users/kk/.pub-cache/hosted/pub.flutter-io.cn/shared_preferences_web-2.0.4/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_plugin_record","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_ios","shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_ios","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2023-04-26 18:10:00.417755","version":"3.7.3"}
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 29
compileSdkVersion 31

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand Down
5 changes: 2 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
buildscript {
// ext.kotlin_version = '1.2.71'
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'

repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
126 changes: 0 additions & 126 deletions example/lib/generated/i18n.dart

This file was deleted.

12 changes: 6 additions & 6 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class MyApp extends StatelessWidget {
"WeChatRecordScreen": (BuildContext context) =>
new WeChatRecordScreen(),
"PathProviderScreen": (BuildContext context) =>
new PathProviderScreen(),
new PathProviderScreen(title: "PathProviderScreen",),
},
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;

@override
Expand All @@ -51,22 +51,22 @@ class _MyHomePageState extends State<MyHomePage> {
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new FlatButton(
new TextButton(
onPressed: () {
Navigator.pushNamed<dynamic>(context, "RecordScreen");
},
child: new Text("进入语音录制界面")),
new FlatButton(
new TextButton(
onPressed: () {
Navigator.pushNamed<dynamic>(context, "RecordMp3Screen");
},
child: new Text("进入录制mp3模式")),
new FlatButton(
new TextButton(
onPressed: () {
Navigator.pushNamed<dynamic>(context, "WeChatRecordScreen");
},
child: new Text("进入仿微信录制界面")),
new FlatButton(
new TextButton(
onPressed: () {
Navigator.pushNamed<dynamic>(context, "PathProviderScreen");
},
Expand Down
Loading