Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example do not work #2

Closed
tabuz opened this issue Mar 23, 2018 · 10 comments
Closed

Example do not work #2

tabuz opened this issue Mar 23, 2018 · 10 comments

Comments

@tabuz
Copy link

tabuz commented Mar 23, 2018

I'm trying to play a bit with your plugin but I can't get example running.
Recording seems to be working as I can see feedback with power of microphone,
calling startPlay method returns FAIL.

I use SDK 27, Flutter: 0.1.5

I/flutter ( 8509): PARAMS{file: 1521839341296, position: 0.0}
E/MethodChannel#medcorder_audio( 8509): Failed to handle method call
E/MethodChannel#medcorder_audio( 8509): java.lang.NullPointerException: context param can not be null.
E/MethodChannel#medcorder_audio( 8509): 	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1036)
E/MethodChannel#medcorder_audio( 8509): 	at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1003)
E/MethodChannel#medcorder_audio( 8509): 	at android.media.MediaPlayer.create(MediaPlayer.java:910)
E/MethodChannel#medcorder_audio( 8509): 	at android.media.MediaPlayer.create(MediaPlayer.java:887)
E/MethodChannel#medcorder_audio( 8509): 	at android.media.MediaPlayer.create(MediaPlayer.java:866)
E/MethodChannel#medcorder_audio( 8509): 	at co.medcorder.medcorderaudio.MedcorderAudioPlugin.startPlay(MedcorderAudioPlugin.java:227)
E/MethodChannel#medcorder_audio( 8509): 	at co.medcorder.medcorderaudio.MedcorderAudioPlugin.onMethodCall(MedcorderAudioPlugin.java:90)
E/MethodChannel#medcorder_audio( 8509): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#medcorder_audio( 8509): 	at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:133)
E/MethodChannel#medcorder_audio( 8509): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#medcorder_audio( 8509): 	at android.os.MessageQueue.next(MessageQueue.java:325)
E/MethodChannel#medcorder_audio( 8509): 	at android.os.Looper.loop(Looper.java:142)
E/MethodChannel#medcorder_audio( 8509): 	at android.app.ActivityThread.main(ActivityThread.java:6494)
E/MethodChannel#medcorder_audio( 8509): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#medcorder_audio( 8509): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E/MethodChannel#medcorder_audio( 8509): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I/flutter ( 8509): startPlay: fail

Would you be able to help with it?
Many Thanks


# Edit:

I found the issue:
there is context assignment missing in plugin java file MedcorderAudioPlugin.java

You just need to update it so it is:

 MedcorderAudioPlugin(Activity _activity) {
    this.activity = _activity;
    this.context = activity.getApplicationContext();
  }
@matejthetree
Copy link

matejthetree commented Apr 2, 2018

@tabuz can you maybe create a fork with a fix, I would like to use your code while we wait for pull request or fix. thx.

@tabuz
Copy link
Author

tabuz commented Apr 2, 2018

@matejthetree
Copy link

matejthetree commented Apr 2, 2018

Hey bro, I get this with your fork
https://gist.github.com/matejthetree/9efc277187f171e0dd32366464d5df70

I am just trying to initialize it

MedcorderAudio _audioPlayer = new MedcorderAudio();

@tabuz
Copy link
Author

tabuz commented Apr 3, 2018

Weird looking error. Nothing comes to my mind. If you want to share the source i might have a look a try to help then. Does the example project from medcorder_audio plugin works fine for you?

@matejthetree
Copy link

adding this after line 23 in android/build.gradle resolves java warning

    gradle.projectsEvaluated {
        tasks.withType(JavaCompile) {
            options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
        }
    }

@john2088
Copy link

not work for me

@jeanpaulcozzatti
Copy link

i had an app that was working for me.
now i get this, even with the example.

perhaps related underlying cause: ? flutter/flutter#15654
i'm going to have to switch libraries...

2018-05-01 10:17:34.627949-0700 Runner[52813:1608279] flutter: Observatory listening on http://127.0.0.1:61887/
2018-05-01 10:17:34.786834-0700 Runner[52813:1608248] flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
2018-05-01 10:17:34.793689-0700 Runner[52813:1608248] flutter: The following assertion was thrown attaching to the render tree:
2018-05-01 10:17:34.794099-0700 Runner[52813:1608248] flutter: type '(Map<String, dynamic>) => void' is not a subtype of type '(dynamic) => void'
2018-05-01 10:17:34.803361-0700 Runner[52813:1608248] flutter:
2018-05-01 10:17:34.803674-0700 Runner[52813:1608248] flutter: Either the assertion indicates an error in the framework itself, or we should provide substantially

@ThinkDigitalSoftware
Copy link

I'm getting the same error as @jeanpaulcozzatti

@jeanpaulcozzatti
Copy link

I've forked and patched the repo here: https://github.com/jeanpaulcozzatti/flutter_audio

@dimmetrius
Copy link
Contributor

New version with Dart 2 Compatibility published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants