Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

Null when getURL() invoked #19

Closed
ArvinCS opened this issue Dec 8, 2019 · 16 comments
Closed

Null when getURL() invoked #19

ArvinCS opened this issue Dec 8, 2019 · 16 comments
Labels
Bug Something isn't working Help wanted Extra attention is needed

Comments

@ArvinCS
Copy link

ArvinCS commented Dec 8, 2019

java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String danielr2001.audioplayer.models.AudioObject.getUrl()' on a null object reference
E/AndroidRuntime(13097): at danielr2001.audioplayer.audioplayers.ForegroundAudioPlayer.initExoPlayer(ForegroundAudioPlayer.java:215)
E/AndroidRuntime(13097): at danielr2001.audioplayer.audioplayers.ForegroundAudioPlayer.play(ForegroundAudioPlayer.java:238)

That's the error that show up everytime i want to play a song, thank you!
It's foreground mode

@danielR2001
Copy link
Owner

Hi, could you attach the code causing this error?

@ArvinCS
Copy link
Author

ArvinCS commented Dec 11, 2019

void _play() async { await widget.music.getAudioURL().then( (String url) { AudioNotification audioNotif = AudioNotification( smallIconFileName: "ic_launcher", title: widget.music.title, subTitle: "by ${widget.music.artist.toString()}", largeIconUrl: widget.music.thumbnail, isLocal: widget.music.isOffline(), notificationDefaultActions: NotificationDefaultActions.ALL, ); debugPrint("player: ${getMPlayer().toString()}"); debugPrint("notif: ${audioNotif.toString()}"); debugPrint("url: ${url.toString()}"); getMPlayer().play(url.toString(), respectAudioFocus: true, playerMode: PlayerMode.FOREGROUND, audioNotification: audioNotif, repeatMode: repeat, position: Duration(milliseconds: 0)); setCurrentMusic(widget.music); } ); setState(() => _playerState = PlayerState.PLAYING); }
Sorry, there was no log about my code that causing that error, only code from yours.
But maybe this can help you :D

@danielR2001
Copy link
Owner

danielR2001 commented Dec 11, 2019

you can enable log with this line: AudioPlayer.logEnabled = true;

@danielR2001
Copy link
Owner

also what version are you using?

@ArvinCS
Copy link
Author

ArvinCS commented Dec 11, 2019

Tried it and the log showed nothing, I'm using lastest version

@ArvinCS
Copy link
Author

ArvinCS commented Dec 11, 2019

Sometimes the player work with no error, but sometimes it errors

@ArvinCS
Copy link
Author

ArvinCS commented Dec 11, 2019

I found what causing that error, it's onAudioSessionIdChange event.
Everytime i listen to that stream, it always crashed when i wanna play a music.
Good luck!

@ArvinCS
Copy link
Author

ArvinCS commented Dec 12, 2019

Wait, I'm not sure about it.

@ArvinCS
Copy link
Author

ArvinCS commented Dec 12, 2019

E/AndroidRuntime(20423): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String danielr2001.audioplayer.models.AudioObject.getUrl()' on a null object reference
E/AndroidRuntime(20423): at danielr2001.audioplayer.audioplayers.ForegroundAudioPlayer.initExoPlayer(ForegroundAudioPlayer.java:215)
E/AndroidRuntime(20423): at danielr2001.audioplayer.audioplayers.ForegroundAudioPlayer.play(ForegroundAudioPlayer.java:238)
E/AndroidRuntime(20423): at danielr2001.audioplayer.AudioPlayerPlugin$1.onServiceConnected(AudioPlayerPlugin.java:75)
E/AndroidRuntime(20423): at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:1652)
E/AndroidRuntime(20423): at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:1681)
E/AndroidRuntime(20423): at android.os.Handler.handleCallback(Handler.java:790)
E/AndroidRuntime(20423): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(20423): at android.os.Looper.loop(Looper.java:164)
E/AndroidRuntime(20423): at android.app.ActivityThread.main(ActivityThread.java:6494)
E/AndroidRuntime(20423): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(20423): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E/AndroidRuntime(20423): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

@danielR2001
Copy link
Owner

As I can see from the logs the player crushes because the JAVA AudioObject is not being created properly for some reason, I will look at it in the evening or tomorrow. Thanks for pointing out the bug.

@danielR2001 danielR2001 added the Bug Something isn't working label Dec 12, 2019
@ArvinCS
Copy link
Author

ArvinCS commented Dec 13, 2019

Good luck! Hope you fix it asap.

@ArvinCS
Copy link
Author

ArvinCS commented Dec 13, 2019

Any news?

@ArvinCS
Copy link
Author

ArvinCS commented Dec 15, 2019

Hi, so you dont have time to fix it? I need your plugin to continue my project tbh

@danielR2001
Copy link
Owner

Sorry, I have a very busy schedule in the last past weeks. If you know JAVA you are more than welcome to try and fix the issue.

@ArvinCS
Copy link
Author

ArvinCS commented Dec 16, 2019

I'm trying to fix the issue, but I'm not sure i can fix it because it doesn't show any error log since i upgraded my flutter to lastest. It makes me hard to find the bug. But i will do my best :)

@danielR2001
Copy link
Owner

Thanks! I really appreciate your help!

@danielR2001 danielR2001 added the Help wanted Extra attention is needed label Jan 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Something isn't working Help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants